itsfrank / frktest

A basic test framework for Lune
MIT License
5 stars 1 forks source link

Feat: Maybe do something with nested suites? #4

Open itsfrank opened 3 days ago

itsfrank commented 3 days ago

Currently suites can be nested and they work, e.g.:

test.suite("A collection of test cases", function()
    test.case("case 1", function()
        check.is_true(false)
    end)

    test.suite("A nested suite", function()
        test.case("Case in a nested suite", function()
            check.is_true(false)
        end)
    end)
end)

This actually works fine, but there is no indication of the nesting in the output:

Screenshot 2024-11-05 at 10 52 23 AM

Would need to figure out 2 things:

  1. How to nicely report this, e.g. indent 1 level further? Combine suite names? etc..
  2. Interaction with focus/skip I think the most sensible way is for nested suites to inherit parent's focus/skip state? Focus in a nested suite should certainly not run parent suite's tests
itsfrank commented 3 days ago

The use-case here is probably for data-driven testing where a collection of tests are run on each element, one could wrap the nested suite in a for loop or something? I haven't had a need for this yet, so I wont work on this for now, but open to revisiting!