unit testing - How can I invoke assertXXX manytimes using setUp() and tearDown() -


I'm using JUnit I want to emphasize the test method many times in order to test many test test cases , But I do not want to do several test methods, so I use setup () and Tyride () but when the first assertEquals () fails. The second assertEquals () does not work and the setup () method has just been implemented once.

Here is my code

  Expands Public Class ComputeServiceTest TestCase {Personal ComputeServices Example = New ComputeServices (); Public computeServiceTest (string name) {super (name); } Protected Zero Set Up () {System.out.println ("AceaAuAuaA"); Example = New Compute Services (); } Protected Zero TierDown () {} // test add method Public Zero TestAd 1 () {// Example = New Compute Services (); // The first test case is x1 = 7; Int y1 = 5; Int expResult1 = 13; Int result1 = instance.add (x1, y1); AssertEquals ("First test case failed", expresult1, result1); // The second examination case System.out.println ("AAAAAAAAAAAAAAAAAAAAAaAaAaaAaaaa"); Int x2 = 9; Int y2 = 6; Int expResult2 = 16; Int result2 = instance.add (x2, y2); AssertEquals ("second test case failed", expResult2, result2); } 

"text">

Try to experiment.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -