Changes between Initial Version and Version 1 of unitpy


Ignore:
Timestamp:
08/21/24 10:48:05 (2 months ago)
Author:
wouter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • unitpy

    v1 v1  
     1= UnitPy
     2
     3UnitPy is a toolbox with python annotations similar to the java unit test annotations, using @Test @Before @After @RunWith etc. UnitPy also provides a tool to discover and run tests.
     4
     5UnitPy does not need the test class to extend unittest.TestCase, and the test class constructor does not need modifications (TestCase requires the name of the test function to be passed as additional argument). This enables to use the test class also as normal class.
     6
     7The @RunWith annotation is to be placed right before the class definition.
     8@RunWith allows the class to be run in different "styles", depending on the argument provided to @RunWith.
     9
     10||= annotation =||
     11||{{{@RunWith(JUnit4ClassRunner)}}}||normal test||
     12||{{{@RunWith(Parameterized)}}}||parametric test||
     13
     14== JUnit4ClassRunner
     15This runs all methods annotated with @Test inside the class.
     16If there is a method annotated @Before, this is called first.
     17Then the test method is called (with no arguments)
     18Finally, if there is a method annotated @After, that method is called
     19
     20
     21== Parameterized
     22The class must contain a static method annotated with @Parameters.   
     23This annotation indicates that the method takes no parameters
     24and that it returns list of lists. Every inner list
     25is to be used to call the constructor, so the number
     26of arguments must match the __init__ function parameters.
     27
     28For every method M inside the class that is annotated with @Test, the following now happens:
     29* create an instance of the test class, with the next inner list arguments
     30If there is a method annotated @Before, this is called.
     31* execute the test method M
     32* if there is a method annotated @After, that method is called