![](/img/trans.png)
[英]Can't run my test from only one class using testNG, maven, NetBeans
[英]Netbeans + Maven + TestNG - How to run test suites from netbeans?
我在項目的測試包中有測試。 我在“測試軟件包”內的軟件包中也有一些suites.xml文件。
例如:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="automation_chrome">
<test name="All tests running in Chrome">
<parameter name="browser" value="chrome"></parameter>
<classes>
<class name="com.company.testsuites.LoginTest">
<methods>
<include name="successfulLogin" />
</methods>
</class>
</classes>
</test>
</suite>
測試用例:
package com.company.testsuites;
import com.company.generictestssuites.MainTest;
import org.testng.Assert;
import org.testng.annotations.Test;
public class LoginTest extends MainTest {
@Test
public void successfulLogin() throws Exception {
login("user1@test.com", "123password1");
Assert.assertEquals(loginPage.getUserLoged(), "Test User 1");
}
}
我可以右鍵單擊測試,然后選擇“測試文件”選項來運行它。 但是,當我右鍵單擊suite.xml來運行測試時,它不會運行測試。
結果如下:
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
我究竟做錯了什么? 我需要解決此問題,以便能夠通過Maven從Jenkins運行測試。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<parallel>methods</parallel>
<threadCount>3</threadCount>
<suiteXmlFiles>
<suiteXmlFile>chrome.xml</suiteXmlFile>
<suiteXmlFile>firefox.xml</suiteXmlFile>
<suiteXmlFile>iexplorer.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
可悲的是,我找不到任何完整的文檔來做到這一點。
我可以通過以下兩個更改使其工作:
1-在POM文件中:
<suiteXmlFiles>
<suiteXmlFile>${project.build.testSourceDirectory}/chrome.xml</suiteXmlFile>
<suiteXmlFile>${project.build.testSourceDirectory}/firefox.xml</suiteXmlFile>
<suiteXmlFile>${project.build.testSourceDirectory}/iexplorer.xml</suiteXmlFile>
</suiteXmlFiles>
2-將xml文件(套件)移動到TestPackages中的默認軟件包。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.