在Jenkins上运行我的Testng测试套件时出现问题

时间:2013-04-17 19:21:47

标签: maven selenium jenkins testng surefire

这是我看到的堆栈跟踪错误

[INFO] --- maven-surefire-plugin:2.8.1:test (default-test) @ eselenium-smartpearsonplayer-pageobjects ---
[INFO] Surefire report directory: c:\jenkins\workspace\MediaPlayerTest\target\surefire-reports
There are no tests to run.

我知道这可能是由于任何事情。所以,让我试着给你更多的信息,虽然这是一个很长的镜头,也许你可以提供帮助。 我使用selenium webdriver 2.29编写测试。 我也在和maven一起建设。 我正在尝试使用testng来配置我正在使用的测试。 我正在使用jenkins运行maven项目,我正在尝试“清理验证”,有时“干净测试”,因为我不知道两者之间的区别。

当地我正在使用eclipse。在本地我可以使用maven测试在maven上运行测试,并使用maven验证。

这是我的pom中的一些东西。

<!-- attempt to use surefire to run tests -->
            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.8.1</version>
                <configuration>
                    <suiteXmlFiles>
                             <suiteXmlFile>src\test\resources\testng\TestBrowserPOC_Test.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
            <!-- end attempt -->

同样,当我在日食上进行maven验证时,测试运行正常。

这是我的testng xml。

<!DOCTYPE Suite SYSTEM "http://testng.org/testng-1.0.dtd">
    <suite name="BrowserPOC_Tests">

        <!-- class does not exist -->
        <!-- <test name="Demo Test"> <parameter name="url"     value="src/test/resources/testData/login.html"></parameter> 
            <groups> <run> <exclude name="errorDetector"></exclude> </run> </groups> 
            <classes> <class name="com.pearson.demotests.DemoTestIT" /> </classes>         </test> -->
        <test name="POC test">
            <groups>
                <run>
                    <include name="volumeTest"></include>
                </run>
            </groups>
            <classes>
                <class name="com.pearson.poc_tests.BrowserPOCIT" />
            </classes>
        </test>
</suite>

现在我将尝试更改我的xml的名称以遵循“命名约定”,看看是否有任何作用。再次,测试在日食上运行良好,而不是在詹金斯上。我不知道该怎么做,或者我需要什么其他信息。我从这里开始的步骤只是为了得到jenkins专家的更多帮助。

哦,我认为我的测试xml的命名约定是正确的。 我也认为我正在使用一个构建为maven的自由式项目。 我应该使用“mvn clean test”而不是“clean test”吗?

2 个答案:

答案 0 :(得分:1)

谢谢大家。事实证明我在jenkins配置中有两个存储库。詹金斯在错误的项目中寻找测试。

答案 1 :(得分:0)

我过去使用过maven故障安全插件。以下是我的配置。你可以运行mvn clean verify。始终建议mvn clean,因为它会在编译和运行测试之前删除目标目录。

<properties>
        <functionalSourceDirectory>src/itest</functionalSourceDirectory>
</properties>

<plugin>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.11</version>
    <configuration>
       <testSourceDirectory>${functionalSourceDirectory}</testSourceDirectory>
       <suiteXmlFiles>
         <suiteXmlFile>src/itest/resources/testng.xml</suiteXmlFile>
       </suiteXmlFiles>
     </configuration>
     <executions>
        <execution>
           <id>verify</id>
           <phase>verify</phase>
           <goals>
             <goal>verify</goal>
           </goals>
        </execution>
     </executions>
 </plugin>