Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.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 为前端测试自动启动/停止web服务器_Java_Maven_Testing_Configuration_Embedded Tomcat 7 - Fatal编程技术网

Java 为前端测试自动启动/停止web服务器

Java 为前端测试自动启动/停止web服务器,java,maven,testing,configuration,embedded-tomcat-7,Java,Maven,Testing,Configuration,Embedded Tomcat 7,现在,我通过maven分别启动嵌入式tomcat: mvn tomcat7:run 然后运行mvn测试目标。 我的问题是,我可以配置maven以自动完成吗? tomcat必须在所有测试运行之前启动,然后停止 tomcat插件使用以下maven配置: <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId>

现在,我通过maven分别启动嵌入式tomcat:

mvn tomcat7:run
然后运行
mvn测试
目标。 我的问题是,我可以配置maven以自动完成吗?
tomcat
必须在所有测试运行之前启动,然后停止

tomcat插件使用以下maven配置:

        <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.1</version>
            <configuration>
                <path>/SpringMvcExample</path>
                <url>http://localhost:8080/manager/text</url>
                <server>tomcat7</server>
            </configuration>
        </plugin>
    </plugins>

org.apache.tomcat.maven
tomcat7 maven插件
2.1
/SpringMvcExample
http://localhost:8080/manager/text
tomcat7
我已尝试将插件配置更新为:

    <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.1</version>
        <configuration>
            <path>/SpringMvcExample</path>
            <url>http://localhost:8080/manager/text</url>
            <server>tomcat7</server>
        </configuration>
        <executions>
            <execution>
                <id>start-tomcat</id>
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>run</goal>
                </goals>
            </execution>
            <execution>
                <id>stop-tomcat</id>
                <phase>post-integration-test</phase>
                <goals>
                    <goal>shutdown</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

org.apache.tomcat.maven
tomcat7 maven插件
2.1
/SpringMvcExample
http://localhost:8080/manager/text
tomcat7
启动雄猫
预集成测试
跑
阻止雄猫
整合后测试
关闭
但它并没有帮助将tomcat:run附加到预集成测试
        attach tomcat:run to pre-integration-test
        attach tomcat:shutdown to post-integration-test
Below is the code snippet. 
    <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.1</version>
       <executions>
          <execution>
            <id>tomcat-run</id>
            <goals>
              <goal>run-war-only</goal>
            </goals>
            <phase>pre-integration-test</phase>
                <configuration>

                    <fork>true</fork> 
                </configuration>

           </execution>
           <execution>
            <id>tomcat-shutdown</id>
            <goals>
              <goal>shutdown</goal>
            </goals>
            <phase>post-integration-test</phase>
          </execution>
        </executions>
      </plugin>
将tomcat:关闭连接到集成后测试 下面是代码片段。 org.apache.tomcat.maven tomcat7 maven插件 2.1 雄猫赛跑 只管打仗 预集成测试 真的 tomcat关机 关闭 整合后测试
请指定将这些陈述放在何处?有几个问题。你使用哪个maven版本?在配置中,url和服务器在我的编辑器中是红色的,似乎这里不允许使用元素。第二个问题:如何指定测试是集成?使用的类的名称:SimpleViewController EleniumTest