2013-09-26 54 views
0

我在用java编写selenium webdriver的测试,我用TestNG将它与testlink集成在一起。所以当我运行测试并且运行正确时,它在testlink中正确保存。但是当测试失败时,测试中出现以下错误:测试失败时出现TestLink错误

testlink.api.java.client.TestLinkAPIException:调用者未提供所需的参数状态。

这是我的测试方法:

@Parameters({"nombreBuild", "nombrePlan", "nomTL_validacionCantidadMensajes"}) 
    @Test 
    public void validarMensajes(String nombreBuild, String nombrePlan, String nomTL_validacionCantidadMensajes) throws Exception { 
     String resultado = null; 
     String nota = null; 
     boolean test; 
     try{ 
      homePage = new HomePageAcquirer(driver); 
      homePage.navigateToFraudMonitor(); 
      fraud = new FraudMonitorPageAcquirer(driver); 
      test = fraud.validarCantidadMensajes(); 
      Assert.assertTrue(test); 
      if(test){ 
       resultado = TestLinkAPIResults.TEST_PASSED; 
      }else { 
       nota = fraud.getError(); 
       System.out.println(nota); 
       resultado = TestLinkAPIResults.TEST_FAILED; 
      } 
     }catch (Exception e){ 
      resultado = TestLinkAPIResults.TEST_FAILED; 
      nota = fraud.getError(); 
      e.printStackTrace(); 
     }finally{ 
      ResultadoExecucao.reportTestCaseResult(PROJETO, nombrePlan, nomTL_validacionCantidadMensajes, nombreBuild, nota, resultado); 
     } 
    } 

XML被罚款怎么一回事,因为当测试通过它的工作原理。

并设置值的testlink方法。

public static void reportTestCaseResult(String projetoTeste, String planoTeste, String casoTeste, String nomeBuild, String nota, String resultado) throws TestLinkAPIException { 
    TestLinkAPIClient testlinkAPIClient = new TestLinkAPIClient(DEVKEY, URL); 
    testlinkAPIClient.reportTestCaseResult(projetoTeste, planoTeste, casoTeste, nomeBuild, nota, resultado); 

} 

回答

1

我想原因是,你永远不会得到这个条件

Assert.assertTrue(test); 
if(test){ 
    resultado = TestLinkAPIResults.TEST_PASSED; 
} else { 
    // 
} 

当阿瑟出现故障,else块新AssertionError发生,所以你永远不会使它甚至如果条件。您也无法捕获此错误,因为Exception也源自ThrowableError。所以你基本上可以删除条件,并试图捕捉Error - 这不是最好的做法,但它会起作用。在这些情况下使用最好的东西是listener,但我不确定它如何与@Parameters一起使用。然而,你总是可以这样做

try{ 
    Assert.assertTrue(test); 
    resultado = TestLinkAPIResults.TEST_PASSED; 
} catch (AsertionError e){ 
    resultado = TestLinkAPIResults.TEST_FAILED; 
    nota = fraud.getError(); 
    e.printStackTrace(); 
}finally{ 
    ResultadoExecucao.reportTestCaseResult(PROJETO, nombrePlan, nomTL_validacionCantidadMensajes, nombreBuild, nota, resultado); 
} 
+0

感谢回复它的完美,将去看听者。 – elcharrua

+0

根据你的个人资料 - 很高兴如果你upvote或接受答案,当你发现它有用,这将激励人们给你一些答案 –

+0

对不起,我没有意识到我没有接受答案,谢谢你让我知道这一点。 – elcharrua

相关问题