【问题标题】:Only 1 test class is running and TestNG execution hangs只有 1 个测试类正在运行并且 TestNG 执行挂起
【发布时间】:2017-06-15 03:55:57
【问题描述】:

我有 2 个测试课程 - 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 个测试已执行,来自 UserTests 的 1 个测试(/users)开始了,它只挂在那里

当我在testng.xml 中将UserTests 移动到PostTests 上方时,UserTests 的所有测试都在执行,而当PostTests 的1 个测试开始时它会挂起。

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

【问题讨论】:

  • 您的 xml 看起来不错,因此可能取决于实际测试本身。请发布更多关于实际测试的信息。你在使用任何 groupDependencies 吗?您是并行还是顺序运行测试?

标签: maven testng jira-rest-api


【解决方案1】:

你能把这些类归为一类吗

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

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

连接是否在每个类中单独创建。

【讨论】:

  • 你是正确的 Monis,它在更改客户端对象的访问说明符后得到解决。早期的相同连接用于调用这两个类。将其更改为单独连接后,它起作用了。谢谢兄弟
猜你喜欢
  • 1970-01-01
  • 2019-06-07
  • 1970-01-01
  • 1970-01-01
  • 2019-02-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多