我需要在我的简单selenium代码中摆脱错误“java.util.ConcurrentModificationException”

时间:2018-05-01 07:59:15

标签: java selenium selenium-webdriver annotations testng

  
      
  1. 下面是一个非常简单的用于理解Testng的代码,但是我遇到了一个问题 - > [TestNG] Reporter org.testng.reporters.JUnitReportReporter@82d64失败了   java.util.ConcurrentModificationException

  2.   
  3. 如何在以下代码中避免/处理此错误。

  4.   
package demotestng2;

import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod; 
import org.testng.annotations.AfterMethod; 
import org.testng.annotations.DataProvider; 
import org.testng.annotations.BeforeClass; 
import org.testng.annotations.AfterClass; 
import org.testng.annotations.BeforeTest; 
import org.testng.annotations.AfterTest; 
import org.testng.annotations.BeforeSuite; 
import org.testng.annotations.AfterSuite;


 public class simpletestngtrycheckannotopttry1 {        
    /*  
       @Test(dataProvider = "dp")   public void f(Integer n, String s) {   }
    */

     @Test
     public void testCase1() {
        System.out.println("This is my First Test Case 1");
     }

     @BeforeMethod
     public void beforeMethod() {
        System.out.println(" Before Method will execute before every test method");
     }


     @AfterMethod
     public void afterMethod() {
         System.out.println("After Method will execute after every test method");
     }


    /*
     @DataProvider
     public Object[][] dp() {
           return new Object[][] {
                new Object[] { 1, "a" },
                new Object[] { 2, "b" },
           };
     }

    */

     @BeforeClass
     public void beforeClass() {
           System.out.println("Before Class will always execute prior to Before Method and Test Method ");
     }

     @AfterClass
     public void afterClass() {
         System.out.println("After Class will always execute later to After Method and Test method");

     }

     @BeforeTest
     public void beforeTest() {
          System.out.println("Before Test will always execute prior to Before Class, ,Before Method and Test Method ");
     }


     @AfterTest
     public void afterTest() {
         System.out.println("After Test will always execute later to After Method, After Class ");
     }

     @BeforeSuite
     public void beforeSuite() {
          System.out.println("Before Suite will always execute prior to all annotations or tests in the suite.");
     }

     @AfterSuite
     public void afterSuite() {
         System.out.println("After suite will always execute at last when all the annotations or test in the suite have run.");
     }

}

1 个答案:

答案 0 :(得分:1)

这是一个众所周知的issue

请更新您的TestNG版本,here您可以找到所有版本。