title: Running Junit test in loop and continuing further if one in between fail
body: <p>I have five diffrent test data and run the (same) JUnit test in loop (five times). That is, with each loop iteration, new Test input data will be read from JSON files and the test will be run, which basically does AsertEquals.</p>
  
  <p>I very well know that JUnit parameterization suits this scenario best but for a moment I have to stick to running test with different test data in loop. </p>
  
  <p>My test basically looks like this:</p>
  
  <pre><code>for (int i = 0; i &lt; tests.length; i++) {
              int test = tests[i];
                         logger.info("---------------------------------------------------------------------------------------------------------------------------------------------------" +
                      "--------------------------------------------------------------------------------------------------------------------------------------------------------");
              logger.info("Executing Test: " + tests[i]);
              logger.info("Json file for Test " + tests[i] + "  is " + file);
              logger.info("---------------------------------------------------------------------------------------------------------------------------------------------------" +
                      "--------------------------------------------------------------------------------------------------------------------------------------------------------");
              FileReader fr = new FileReader(file);
              kparams = readKernelParameters.readJsonFile(fr);
              setUpMatrices();
              setUpKernel();
              setUpPSM();
              if (!setUpFailure) {
                  logTestConfiguration();
                  if (logPsmOutput) {
                      File testFile = getPSMFileOutput();
                      write(testFile, Matrix.transpose(velocity));
                  }
                  if (testsToBeRun[i] == 5) {
                      Assert.assertNotEquals("Running PSM Check " + tests[i] + ": ", 0f, (double) Matrix.diff(vOut, velocity, quality)[6], 1.0f);
  //here I want to check if above Assert.assertNotEquals was successful, if yes //then I would like to write in log file
                  } else {
                      Assert.assertEquals("Running PSM Check " + tests[i] + ": ", 0f, (double) Matrix.diff(vOut, velocity, quality)[6], 1.0f);
  //same here
                  }
              } else {
                  Log.error("Failure in test setup");
                  Assert.fail("Failure in test setup");
              }
          }
  </code></pre>
  
  <p>Now I have following questions:</p>
  
  <p>1) How do I check if Assert.asserEquals and Assert.assertNotEquals was successful ? since they return void I can not write them in if condition. is there any other way I can check it ?</p>
  
  <p>2) Currently, what happens is, if one test fails for e.g. Test -2, then it does not run the loop further and exits. Whereas I would like to iterate further and run further tests.</p>
  
  <p>I know my for loop for this scenario may not be good, but I am wondering if I can achieve what I want to with it.</p>