只有一个测试类正在运行且TestNG执行挂起

时间:2017-01-30 02:39:44

标签: maven testng jira-rest-api

我有两个测试类 - PostTestsUserTests。我在testng.xml文件中指定了它们,当使用maven运行时,我发现testng中第一个指定类的所有方法都在运行并且它挂起....类2方法没有运行。它挂了。 你能帮我解决一下我做错了什么。

以下是我的testng.xml

<suite name="TestAll">
  <test name="post">
    <classes>
      <class name="com.vin.vinapi.PostTests"/>
    </classes>
  </test>
  <test name="user">
    <classes>
      <class name="com.vin.vinapi.UserTests"/>
    </classes>
  </test>
</suite>

以下是执行输出

[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building vinapi 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.google.code.gson:gson:jar:2.2.4 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ vinapi ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/i332939/Documents/workspace/vinapi/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ vinapi ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ vinapi ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/i332939/Documents/workspace/vinapi/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ vinapi ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ vinapi ---
[INFO] Surefire report directory: /Users/i332939/Documents/workspace/vinapi/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Request URL : https://jsonplaceholder.typicode.com/posts
Response Code : 200
Request URL : https://jsonplaceholder.typicode.com/posts/2
Response Code : 200
Request URL : https://jsonplaceholder.typicode.com/users

正如您所看到的,PostTests.java/posts/posts/2)执行了2次测试,/users执行了1次测试(UserTests)并挂起只有

当我将UserTests移到PostTests testng.xml以上时,UserTests的所有测试都在执行,当PostTests的1次测试开始时,它会挂起。< / p>

通过命令行或通过eclipse运行时输出相同。

1 个答案:

答案 0 :(得分:1)

请你把课程分组在一个类中,比如

 <suite name="TestAll">
   <test name="post">
     <classes>
         <class name="com.vin.vinapi.PostTests"/>
         <class name="com.vin.vinapi.UserTests"/>
     </classes>
   </test>
 </suite>

如果它工作正常,那么在处理请求时似乎连接正在进入死锁状态。

是否在每个班级中单独创建了连接。