-
Notifications
You must be signed in to change notification settings - Fork 9
Adds the unittest2ListTests compile time flag
#52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
won't fly - need to do it at runtime really since tests can be added dynamically as well, ie: import unittest2
for i in 0..<10:
test "test" & $i:
echo "hello"
|
|
see also the separate |
Didnt know that was possible but running the test to discover them its a bad idea as it will make the discovery quite slow (i.e. you want to add new tests to the list when the user creates a new test with its own button to run it from the file). |
On the flip side you get to run the test faster when it's done since it's now already compiled so practically, there's no difference in edit-to-test-running time .. ie can display something like "compiling tests.." in the meantime. Collect-then-run is how most xunit-style test frameworks work, with the option to generate test cases on the fly being common - ie it's part of the basic feature set they offer, unittest2 included. Compiled languages have this downside that it takes a while to run the suite but there's little to do to avoid it that is at the same time correct - having an incorrect test parser, or one that works only in trivial cases (where arguably you don't need a test framework or editor support) is kind of useless - ie the gui is only useful if it actually helps with the complex test suites that warrant an IDE to begin with. |
Consider you have a test that takes 2 minutes to run but you only want to run via the runner a suite that takes < 1s to run because you are actually developing that suite.
Right, but they do it mostly at runtime because such languages doesnt have compile time capabilities. AFAIK most .NET frameworks didnt allow to add test to the runner at runtime. Also consider that we are elevating the bar for other libraries to support the test runner (namely the std/unittest one) |
We're not running the test - just running the test collector that prints names - compilation takes whatever it will take as usual.
Dynamic tests are usually about reading files from disk that contain test data, and generating suite interactions based on that - nim also typically does not support this at compile time, except through
https://docs.nunit.org/articles/nunit/writing-tests/attributes/testcasesource.html
"catching up"
std/unittest works / allows this too (except it has some built-in limitations on the test suite size), though it lacks the capability to collect tests before running them (ie it doesn't have the |
listTests compile time flagunittest2ListTests compile time flag
Running:
nim c -d: unittest2ListTests -r tests/sampletests.nimWill result in:
Allowing external tools (i.e. a test runner) to gather test information without actually running the tests