【问题标题】:Netbeans + Maven + TestNG - How to run test suites from netbeans?Netbeans + Maven + TestNG - 如何从 netbeans 运行测试套件?
【发布时间】:2015-02-20 15:10:44
【问题描述】:

我在项目的测试包中有测试。 我在测试包内的包中也有一些 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>

遗憾的是,我找不到任何完整的文档来做到这一点。

【问题讨论】:

    标签: maven netbeans testng


    【解决方案1】:

    我可以通过这两个更改使其工作:

    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 中的默认包。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-13
      • 2012-02-22
      • 2011-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-25
      • 1970-01-01
      相关资源
      最近更新 更多