Have you checked theories ? http://junit.sourceforge.net/doc/ReleaseNotes4.4.html
On Fri, Nov 25, 2011 at 15:28, Emilis <[email protected]> wrote: > Hello, Posse people, > I would like to get some opinions on how to write the unit tests for > the following scenario. > > Let's assume that we are testing some method which should generate to > events: eventA and eventB. Unit test could look like this: > > testEventA() { > // 1. mock eventA listener > // 2. setup the test case > // 3. invoke method > // 4. verify that eventA listener was called correctly > // 5. verify that eventA contains correct values > } > > testEventB() { > // 1. mock eventB listener > // 2. setup the test case > // 3. invoke method > // 4. verify that eventB listener was called correctly > // 5. verify that eventB contains correct values > } > > Assuming that steps 2 and 3 are the same for both tests, do you keep > both tests separate (as above) or do you write testEventAandEventB() > instead? and why? > Bonus question. Let's assume that both tests are testing the same > event now and the only difference between them is steps 2 and 3. What > would be your approach? again, why? > > Regards, > Emilis > > -- > You received this message because you are subscribed to the Google Groups > "The Java Posse" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/javaposse?hl=en. > > -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
