unit testing - How can I run many test cases for a test method -


I am using JUnit. I have a method and a test method to test some test cases. I want to run all TES cases in that test method, but I can not do this. When the case of the first test fails, the examination method does not run for the second exam.

This is my code

  Public Class ComputeServiceTest TestCase {// test add method} Add Public Zero Test () {ComputeServices Example = New ComputeServices (); // 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); // second test case in x2 = 9; Int y2 = 6; Int expResult2 = 15; Int result2 = instance.add (x2, y2); AssertEquals ("second test case failed", expResult2, result2); }  

How can I do this?

The standard advice here is to put your second test case in a different way, even if "before the trial case "Whether successful or not, it can run.

You can use a setup method to start ComputeServices, for example you do not need that boilerplate in each test method.


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" -