Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用jenkins平台在maven项目中运行spock测试_Java_Maven_Jenkins_Spock - Fatal编程技术网

Java 使用jenkins平台在maven项目中运行spock测试

Java 使用jenkins平台在maven项目中运行spock测试,java,maven,jenkins,spock,Java,Maven,Jenkins,Spock,我创建了maven项目,它由junit和spock测试组成。 两个测试的代码 public class AppTest { /** * Rigorous Test :-) */ @Test public void shouldAnswerWithTrue() { assertTrue( true ); } } class SpockTest extends Specification { def "one

我创建了maven项目,它由junit和spock测试组成。 两个测试的代码

public class AppTest 
{
    /**
     * Rigorous Test :-)
     */
    @Test
    public void shouldAnswerWithTrue()
    {
        assertTrue( true );
    }
}

class SpockTest extends Specification  {

    def "one plus one should equal two"() {
        expect:
        1 + 1 == 2
    }

}
在我的本地机器上,当我运行mvn测试时,它会检测两个测试类。 我在git存储库上部署了项目,并为maven项目配置了jenkins。我推送存储库并执行该项目的作业,但jenkins只检测JUnit测试的AppTest类。 我已更改pom.xml并将文件regadring添加到
https://github.com/menonvarun/testInProgress-spock-client
。 我的项目结构

文件org.spockframework.runtime.extension.IGlobalExtension的内容

org.imaginea.jenkins.testinprogress.spock.SpockTestInProgressExtension
pom.xml

<repositories>
    <repository>
      <id>repo.jenkins-ci.org</id>
      <url>http://repo.jenkins-ci.org/public/</url>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.spockframework</groupId>
      <artifactId>spock-core</artifactId>
      <version>1.0-groovy-2.4</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <version>2.4.7</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.imaginea.jenkins.plugins</groupId>
      <artifactId>testInProgress-spock-client</artifactId>
      <version>0.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

repo.jenkins-ci.org
http://repo.jenkins-ci.org/public/
朱尼特
朱尼特
4.11
测试
org.spockframework
斯波克堆芯
1.0-groovy-2.4
测试
org.codehaus.groovy
groovy all
2.4.7
测试
org.imaginea.jenkins.plugins
测试进程spock客户端
0.1
测试

我在jenkins平台上安装了testInProgress插件。之后,我将更改后的maven项目推送到存储库中,并再次为maven项目执行作业。另一次jenkins没有检测到SpockTest类。可能是什么问题?

尝试将spock测试放在
groovy
文件夹下:

  • src
    • 试验
      • 棒极了
        • com.jenk。。。
          • SpockTest.groovy
然后将
gmavenplus插件
(groovy编译器)和
maven surefire插件
(测试运行程序)添加到
pom.xml

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>1.6.2</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
            </plugin>
        </plugins>
    </pluginManagement>

    ...

    <plugins>
        <plugin>
            <groupId>org.codehaus.gmavenplus</groupId>
            <artifactId>gmavenplus-plugin</artifactId>
            <configuration>
                <targetBytecode>1.8</targetBytecode>
                <warningLevel>2</warningLevel>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>compileTests</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
        </plugin>
    </plugins>

尝试将spock测试放在
groovy
文件夹下:

  • src
    • 试验
      • 棒极了
        • com.jenk。。。
          • SpockTest.groovy
然后将
gmavenplus插件
(groovy编译器)和
maven surefire插件
(测试运行程序)添加到
pom.xml

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>1.6.2</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
            </plugin>
        </plugins>
    </pluginManagement>

    ...

    <plugins>
        <plugin>
            <groupId>org.codehaus.gmavenplus</groupId>
            <artifactId>gmavenplus-plugin</artifactId>
            <configuration>
                <targetBytecode>1.8</targetBytecode>
                <warningLevel>2</warningLevel>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>compileTests</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
        </plugin>
    </plugins>