You may wish to share the code written in setUp() and tearDown() methods of your JUnit tests. This clearly will indicate that you have excessive coupling in your design. Coupling is not bad always but if more tests share the same test fixture state, then this indicates that the classes under test have some undesirable dependencies. You may wish to remove these dependencies but its another stories. As I said, coupling or dependencies are not always bad. But if you wish to keep coupling ...
This post presents an example that shows how to use @BeforeClass and @AfterClass annotation. Java Code: public class SimpleTest { private Collection collection; @BeforeClass public static void oneTimeSetUp() { // one-time initialization code } @AfterClass public static void oneTimeTearDown() { // one-time cleanup code ...
public class SimpleTest { private Collection collection; @BeforeClass public static void oneTimeSetUp() { // one-time initialization code } @AfterClass public static void oneTimeTearDown() { // one-time cleanup code
License4J 4.0
05-22-2013, 12:23 AM in Java Software