dimanche 5 mars 2017

Allure reports showing removed tests however testNG showing it correctly

  1. I am reading some data using Data provider in TestNG(using Java)
  2. Based on data values, I skipped few test run

Expectation: These conditionally skipped test should not be part of Allure report

  1. Using IHookable listeners, I added an attribute to all such invalid tests e.g.

    if(condition_not_met){ 
        testResult.setAttribute("disabled", true); 
        throw new SkipException("skipping test");
    }
    
    
  2. Now using ITestListeners > onFinish() method, I collect all Skipped Tests, filter them as per attribute we set i.e. 'disabled' And then remove them using iterator.remove()

     @Override
     public void onFinish(ITestContext context) {
                Iterator<ITestResult> iterator = context.getSkippedTests().getAllResults().iterator();
                while (iterator.hasNext()) {
                        ITestResult result = iterator.next();
                        if (Boolean.parseBoolean(result.getAttribute("disabled").toString())) {
                                  iterator.remove();  
                         }
                 }
     } 
    
    
  3. Now when we run project using 'mvn clean test site' command, TestNG and Allure report get generated.

TestNG report show only passed cases while Allure report show skipped cases also

So my question is why Allure showing removed test while TestNG showing only passed tests?

Aucun commentaire:

Enregistrer un commentaire