steve
steve

Reputation: 483

Jenkins build web application and tests

I'm trying to setup jenkins for testing a web application. For this setup I have a gradle build file.

apply plugin: 'java'
apply plugin: 'maven'
defaultTasks 'clean','compileJava','test'

group = 'automationtest'
version = '1.1-SNAPSHOT'

description = ""

repositories {

     maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version:'2.52.0'
    compile group: 'org.uncommons', name: 'reportng', version:'1.1.4'
    compile group: 'org.apache.velocity', name: 'velocity', version:'1.7'
    compile group: 'com.google.inject', name: 'guice', version:'4.0'
    testCompile group: 'junit', name: 'junit', version:'3.8.1'
    testCompile group: 'org.testng', name: 'testng', version:'6.9.4'
}
test{

    useTestNG() {
        suites "src/test/resources/BasicTestXML/LoginTesten.xml"
    }
}

With the above build file I can perfectly run my automation test in jenkins, if I have a localhost running for the application. But to make it less dependable of human interaction I want to have jenkins first build the web application and after that run the automation tests on the built web application. Is this possible? And how can I make this happen? Can I build them from git or do they need to be at the same location for this to happen? The webapp is also an ant project so does this bring any difficulties?

Upvotes: 0

Views: 1412

Answers (1)

Vampire
Vampire

Reputation: 38639

If you want to make it even Jenkins independent, you can e. g. make your Gradle build trigger the Ant build that builds the web application and then deploy the result somewhere, starting a container to deploy to. Then after the tests are finished your gradle build can stop the running container again.

Upvotes: 1

Related Questions