-
Notifications
You must be signed in to change notification settings - Fork 139
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
setup/teardown at class and suite level #61
Comments
Hi, Need more informationUnfortunately I'm not used to use "class testing", I will be glad if anyone could share me a link to his sources showing how he uses it, so I will be able to understand the use-case. Here is a schema about how I'm using Luaunit and how the test execution should be with the enhancement: As you can see, I use a single "test-suite.lua" file that have some requires to other test modules, using tables for grouping tests about the same "module under test" NamesWatching the Luaunit source code, I can see that we can use test class, test function and test tables Report multiple error/failures
Do you mean that if a test have few assertions, all the assertions should be evaluated and all failures are shown in the report ? |
Hi, Thanks for volonteering. You ask many questions, so let me take the time to answer. There are no classes is Lua as you know, so what I actually call "class" is just a table grouping a set of tests. All the xUnit frameworks (Junit, Python unittest, cppunit ...) originate from the java unit test which was based on classes. That's why I am still using the concept of classes although it does not make total sense in the Lua world. The names setUp() and tearDown() also date back from this historical root. That's why I have kept them. To be clearer about the context, let's imagine the following test code :
The order of execution should be:
As you can see, there is no concept of setupTable which would be different from setupClass, it refers to the same topic. For how to test this, it is quite simple : create side-effect in each function setup / teardown and test function, execute this whole subtest suite, and then verify that the side effects have been used in proper order. You can find such examples in test_luaunit.lua, line 3110, function TestLuaUnitExecution:testSetupAndTeardown() I'll get back to you soon with regard to your other remarks. By the way, your link is not working for me... |
@bluebird75 if I open a PR for that, would look at it, or have you stopped supporting the project? Update #1Looks these features are already in 3.4, but not documented. Update #2Naming convention in current implementation (3.4.1):
Noticed that if
Code sample: function TestClassAlpha.setupClass()
error('!! TestClassAlpha.setupClass')
print('> TestClassAlpha.setupClass')
end
function TestClassAlpha.teardownClass()
print('> TestClassAlpha.teardownClass')
end |
Today, luaunit supports setup/teardown to be executed before and after each test. Sometimes, it's convenient to also have per suite setup/teardown function and per class setup/teardown functions.
Proposal :
Up for adoption...
The text was updated successfully, but these errors were encountered: