使用Maven,量angular器和Selenium WebDriver进行集成testing

我们开发了一个Web应用程序,在后端使用Java,在UI中使用Angular,使用Maven作为构build系统。

我一直在尝试使用量angular器来设置自动化的集成testing,并且在Google负载/ StackOverflowing加载之后,仍然无法弄清楚如何实现最终的2端configuration。

Node.js / NPM安装(失败)

我已经尝试使用前端Maven插件来处理Node.js和NPM安装,但是由于我们是在公司防火墙的后面,似乎不可能直接下载任何东西。 虽然它可以从我们的Artifactory下载Node,但是在NPM下载失败(我不明白为什么它甚至会下载它,因为它是Node包的一部分)。 无论如何,我放弃了这个想法,并决定使用本地安装的节点。

启动Tomcat

为e2etesting启动/停止一个Tomcat实例很好地被处理

<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <url>${tomcat.manager.url}</url> <path>/</path> <server>Tomcat</server> </configuration> <executions> <!-- Starting Tomcat --> <execution> <id>start-tomcat</id> <phase>pre-integration-test</phase> <goals> <goal>run</goal> </goals> <configuration> <!-- Fork the process, otherwise the build will be blocked by the running Tomcat --> <fork>true</fork> <port>${tomcat.port}</port> <systemProperties> <!-- We want to use the 'e2e' profile for integration testing --> <spring.profiles.active>e2e</spring.profiles.active> </systemProperties> </configuration> </execution> <!-- Stopping Tomcat --> <execution> <id>stop-tomcat</id> <phase>post-integration-test</phase> <goals> <goal>shutdown</goal> </goals> </execution> </executions> </plugin> 

使用WebDriver(失败)

我设法启动WebDriver,但问题是它阻止了进一步的执行:

  <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <executions> <!-- Start webdriver --> <execution> <id>start-webdriver</id> <phase>pre-integration-test</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>webdriver-manager</executable> <arguments> <argument>start</argument> </arguments> </configuration> </execution> </executions> </plugin> 

运行量angular器

鉴于Node.js安装和WebDriver正在运行,这不应该是一个问题。 但是,由于我没有启动WebDriver,所以它继续执行,这是封锁。

任何build议如何WebDriver可以pipe理(开始/停止)?

向Protractorconfiguration文件添加directConnect: true解决了启动/停止WebDriver的问题(正如Nick所build议的那样)。 在这种情况下,必须从POM中删除对WebDriver的任何显式控制。

可用的参数在参考configuration文件中有详细的介绍。