0

J'ai un autre contexte de test avec une logique personnalisée pour importer et lire « testConfigFile »TestNG: - pas en mesure d'obtenir context.getCurrentXmlTest()

Mais < je suis planing pour itérer sur plusieurs tests afin, en essayant pour lire des données de test comme

@DataProvider(name = "testdata") 
    public Object[][] testdata(ITestContext context) { 
     Map<String, String> parameters = context.getCurrentXmlTest() 
       .getAllParameters(); 
     System.out.println("-------"); 

     Iterator it = parameters.entrySet().iterator(); 
     while (it.hasNext()) { 
      Map.Entry pairs = (Map.Entry) it.next(); 

      String x = (String) pairs.getValue(); 

      if (x.startsWith("created_") 
        && !pairs.getKey().toString().contains("shareData")) { 
       String y = (String) universalMap.get(x); 
       parameters.put((String) pairs.getKey(), y); 
      } 
     } 
     return new Object[][] { { parameters } }; 
    } 

où il est pas en mesure de détecter contexte une méthode getCurrentXmlTest() même après la coulée de type comme

Map<String, String> parameters = (((ITestContext)context).getCurrentXmlTest()) 
       .getAllParameters(); 

il jette encore: -

The method getCurrentXmlTest() is undefined for the type ITestContext 

Répondre

0

Oh, j'utilisait très ancienne bibliothèque TestNG testng-5,4-jdk15.jar. Maintenant, je l'ai amélioré et fonctionne bien maintenant.

Merci.