简体   繁体   English

Jenkins中的集成测试

[英]Integration tests in Jenkins

I want to do some integrations tests with Selenium on my Java web application. 我想在我的Java Web应用程序上使用Selenium进行一些集成测试。 I have set up Jenkins to build currently using Ant script. 我已经设置了Jenkins,目前正在使用Ant脚本进行构建。

As I understand it, the web application must be built, packaged and deployed to a running server before it can be tested with Selenium webdriver (on localhost). 据我了解,Web应用程序必须构建,打包并部署到正在运行的服务器,然后才能使用Selenium webdriver(在localhost上)进行测试。 When I do this locally it works fine. 当我在本地这样做时它工作正常。 But on my Jenkins machine I need to start another server other then the one Jenkins run on in order to deploy the war file there and then run the tests right? 但是在我的Jenkins机器上,我需要启动另一个服务器,然后运行Jenkins,以便在那里部署war文件然后运行测试吗? The problem is that deployment is a post-build action and I can't run any tests after that, or can I? 问题是部署是一个构建后的操作,之后我无法运行任何测试,或者我可以吗?

Why don't use Docker for providing building, deploying and testing environments? 为什么不使用Docker来提供构建,部署和测试环境?

It will provide the kind of isolation that you require for building and testing your web app inside your Jenkins server. 它将提供在Jenkins服务器中构建和测试Web应用程序所需的隔离。

You can define different environments to match your project's dependencies using Dockerfiles and building your own container images. 您可以使用Dockerfiles定义不同的环境以匹配项目的依赖项,并构建您自己的容器映像。 Think of containers as very light weight virtual machines. 将容器视为非常轻量级的虚拟机。 In your case, for building and testing your web app I imagine you would need at least a machine with JDK and Selenium Webdriver installed. 在您的情况下,为了构建和测试您的Web应用程序,我想您至少需要一台安装了JDK和Selenium Webdriver的机器。

There are a bunch of images available at the official Docker container registry, Dockerhub which you could use instead of building your own. 在官方Docker容器注册表Dockerhub中可以使用一堆图像,您可以使用它而不是构建自己的图像。

For a nice white paper on getting started using continuous integration with Docker and Jenkins go here 有关开始使用与Docker和Jenkins持续集成的好白皮书请访问此处

you can run definitely. 你可以肯定跑。 You can use different jobs for each step. 您可以为每个步骤使用不同的作业。 pre-build, build, postbuild. 预建,建造,后建。 Jenkins is very flexible tool. 詹金斯是非常灵活的工具。 You need to not worry about doing all steps in a single job. 您不必担心在单个作业中执行所有步骤。 I suggest you write one job for deployment and depending on it's success you can trigger build on another project ie run your sanity tests job. 我建议您为部署编写一个作业,并根据它的成功,您可以触发另一个项目的构建,即运行您的理智测试工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM