I am bit confused about the usage of setUp
method in unittest
From the documentation
setUp()
Method called to prepare the test fixture. This is called immediately before calling the test method; other than AssertionError or SkipTest, any exception raised by this method will be considered an error rather than a test failure. The default implementation does nothing.
Now I understand that setUp
would be called before each testcase from the testsuite.
But if each of the testcase needs to do something else in their respective setUp
and tearDown
, how can I do that in these methods. It seems they are generic for each of the testcases
Since each of the testcase is for the same feature so logically they belong to the same testsuite. I can easily write the setup and teardown steps in the test method itself, but then setUp
and tearDown
would lose its purpose