utest icon indicating copy to clipboard operation
utest copied to clipboard

Unnamed tests sometimes do not run

Open bwbecker opened this issue 9 months ago • 0 comments

The following tests yield my expected results:

    test("utest bug v1") {
      test("0") {
        1 ==> 1
        "one"
      }
      test("1") {
        2 ==> 2
        "two"
      }
    }

that is,

+ oat.degreeAudit.parser.CourseSpecParserTests.utest bug v1.0 0ms  one
+ oat.degreeAudit.parser.CourseSpecParserTests.utest bug v1.1 0ms  two

However, if I make them unnamed, I think the intent is for the output to be identical. Even if not, they should at least run but don't appear to:

    test("utest bug v2") {
      test {      // name removed
        1 ==> 1
        "one"
      }
      test {      // name removed
        2 ==> 2
        "two"
      }
    }

yields

+ oat.degreeAudit.parser.CourseSpecParserTests.utest bug v2 0ms  Apply(two)

The documentation for this feature is now considerably less clear than I remember from when I started using uTest (the connection between "utest.* symbol" and the actual code isn't clear to me), but I think the intent is still that names can be omitted from tests.

Finally, I note that if I remove the returned value it works as expected. That is,

    test("utest bug v3") {
      test {      // name removed
        1 ==> 1
        //"one"
      }
      test {      // name removed
        2 ==> 2
       // "two"
      }
    }

yields

+ oat.degreeAudit.parser.CourseSpecParserTests.utest bug v3.0 0ms  
+ oat.degreeAudit.parser.CourseSpecParserTests.utest bug v3.1 0ms  

I do see the "Apply" in the output for v2 and that the documentation has the body of the test be a function. So I wrote:

    def check(i: Int): String = {
      i ==> i
      i.toString
    }
    test("utest bug v4") {
      test { check(1) }
      test { check(2) }
    }

I think this is equivalent to the documentation. However, it too, does not appear to run all of the nested tests:

+ oat.degreeAudit.parser.CourseSpecParserTests.utest bug v4 0ms  Apply(2)

bwbecker avatar May 15 '24 14:05 bwbecker