【发布时间】:2017-06-15 03:55:57
【问题描述】:
我有 2 个测试课程 - PostTests 和 UserTests。我在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