From 3fffb7234e5d2feaacc745f5c9f9a1cdfd47eec9 Mon Sep 17 00:00:00 2001 From: Marty30 Date: Wed, 21 Jun 2017 13:02:23 +0200 Subject: [PATCH] Selenium now uses the failsafe plugin --- .travis.yml | 13 ++++++- Dockerfile | 34 +++++++++---------- pom.xml | 28 +++++++++++++++ .../{AddOwnerTest.java => AddOwnerIT.java} | 8 ++--- .../nl/utwente/bpsd/selenium/FailingIT.java | 26 ++++++++++++++ .../nl/utwente/bpsd/selenium/FailingTest.java | 28 --------------- .../{FindOwnerTest.java => FindOwnerIT.java} | 10 +++--- ...eniumBaseTest.java => SeleniumBaseIT.java} | 4 +-- 8 files changed, 93 insertions(+), 58 deletions(-) rename src/test/java/nl/utwente/bpsd/selenium/{AddOwnerTest.java => AddOwnerIT.java} (88%) create mode 100644 src/test/java/nl/utwente/bpsd/selenium/FailingIT.java delete mode 100644 src/test/java/nl/utwente/bpsd/selenium/FailingTest.java rename src/test/java/nl/utwente/bpsd/selenium/{FindOwnerTest.java => FindOwnerIT.java} (65%) rename src/test/java/nl/utwente/bpsd/selenium/{SeleniumBaseTest.java => SeleniumBaseIT.java} (92%) diff --git a/.travis.yml b/.travis.yml index e55f2b2b6..d0ad0d56f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,19 @@ addons: jdk: oraclejdk8 +install: + - docker-compose build + +before_script: + - docker-compose up -d + script: - - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar + - mvn verify -Dskip.surefire.tests +# - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar + +after_script: + - docker-compose stop + - docker-compose rm cache: directories: diff --git a/Dockerfile b/Dockerfile index a1c890445..d258da6b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,17 @@ -FROM maven:latest - -# Set the workdir -WORKDIR /app - -# Copy the source to the container -COPY . . - -# Build the project -RUN mvn package - -# Make the jar executable -RUN sh -c 'touch target/spring-petclinic-*.jar' - -#Start the project -ENV JAVA_OPTS="" -ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar target/spring-petclinic-*.jar" ] \ No newline at end of file +FROM maven:latest + +# Set the workdir +WORKDIR /app + +# Copy the source to the container +COPY . . + +# Build the project +RUN mvn package -Dskip.failsafe.tests + +# Make the jar executable +RUN sh -c 'touch target/spring-petclinic-*.jar' + +#Start the project +ENV JAVA_OPTS="" +ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar target/spring-petclinic-*.jar" ] diff --git a/pom.xml b/pom.xml index 757c84577..a0b3f0eba 100644 --- a/pom.xml +++ b/pom.xml @@ -128,6 +128,34 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + ${skip.surefire.tests} + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + ${skip.failsafe.tests} + + + + run-integration-tests + integration-test + + integration-test + verify + + + + org.springframework.boot spring-boot-maven-plugin diff --git a/src/test/java/nl/utwente/bpsd/selenium/AddOwnerTest.java b/src/test/java/nl/utwente/bpsd/selenium/AddOwnerIT.java similarity index 88% rename from src/test/java/nl/utwente/bpsd/selenium/AddOwnerTest.java rename to src/test/java/nl/utwente/bpsd/selenium/AddOwnerIT.java index 888e501c3..de1dfaba9 100644 --- a/src/test/java/nl/utwente/bpsd/selenium/AddOwnerTest.java +++ b/src/test/java/nl/utwente/bpsd/selenium/AddOwnerIT.java @@ -14,14 +14,14 @@ import java.net.MalformedURLException; * @author Martijn * @since 21-6-2017. */ -public class AddOwnerTest extends SeleniumBaseTest { - public AddOwnerTest() throws MalformedURLException { +public class AddOwnerIT extends SeleniumBaseIT { + public AddOwnerIT() throws MalformedURLException { super(); } @Test - @Category(SeleniumBaseTest.class) - public void addOwnerTest() { + @Category(SeleniumBaseIT.class) + public void addOwnerIT() { driver.get(BASE_URL+"/owners/new"); //Add an owner diff --git a/src/test/java/nl/utwente/bpsd/selenium/FailingIT.java b/src/test/java/nl/utwente/bpsd/selenium/FailingIT.java new file mode 100644 index 000000000..87a26e3ad --- /dev/null +++ b/src/test/java/nl/utwente/bpsd/selenium/FailingIT.java @@ -0,0 +1,26 @@ +package nl.utwente.bpsd.selenium; + +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.net.MalformedURLException; + +/** + * @author Martijn + * @since 21-6-2017. + */ +public class FailingIT extends SeleniumBaseIT { + public FailingIT() throws MalformedURLException { + super(); + } + + @Test + @Category(SeleniumBaseIT.class) + @Ignore + public void failIT() { + Assert.fail(); + } + +} diff --git a/src/test/java/nl/utwente/bpsd/selenium/FailingTest.java b/src/test/java/nl/utwente/bpsd/selenium/FailingTest.java deleted file mode 100644 index 403e2ce71..000000000 --- a/src/test/java/nl/utwente/bpsd/selenium/FailingTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package nl.utwente.bpsd.selenium; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.openqa.selenium.By; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; - -import java.net.MalformedURLException; - -/** - * @author Martijn - * @since 21-6-2017. - */ -public class FailingTest extends SeleniumBaseTest { - public FailingTest() throws MalformedURLException { - super(); - } - - @Test - @Category(SeleniumBaseTest.class) - public void failTest() { - Assert.fail(); - } - -} diff --git a/src/test/java/nl/utwente/bpsd/selenium/FindOwnerTest.java b/src/test/java/nl/utwente/bpsd/selenium/FindOwnerIT.java similarity index 65% rename from src/test/java/nl/utwente/bpsd/selenium/FindOwnerTest.java rename to src/test/java/nl/utwente/bpsd/selenium/FindOwnerIT.java index ff6700f6d..17fcd7de4 100644 --- a/src/test/java/nl/utwente/bpsd/selenium/FindOwnerTest.java +++ b/src/test/java/nl/utwente/bpsd/selenium/FindOwnerIT.java @@ -4,8 +4,6 @@ import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; import org.openqa.selenium.By; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; import java.net.MalformedURLException; @@ -14,14 +12,14 @@ import java.net.MalformedURLException; * @author Martijn * @since 21-6-2017. */ -public class FindOwnerTest extends SeleniumBaseTest { - public FindOwnerTest() throws MalformedURLException { +public class FindOwnerIT extends SeleniumBaseIT { + public FindOwnerIT() throws MalformedURLException { super(); } @Test - @Category(SeleniumBaseTest.class) - public void findOwnerTest() { + @Category(SeleniumBaseIT.class) + public void findOwnerIT() { driver.get(BASE_URL+"/owners/find"); fillTextField(By.name("lastName"),"Coleman"); driver.findElement(By.name("lastName")).submit(); diff --git a/src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseTest.java b/src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseIT.java similarity index 92% rename from src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseTest.java rename to src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseIT.java index 8b72d1edf..d4f701966 100644 --- a/src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseTest.java +++ b/src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseIT.java @@ -14,12 +14,12 @@ import java.net.URL; * @author Martijn * @since 21-6-2017. */ -public class SeleniumBaseTest { +public class SeleniumBaseIT { protected final RemoteWebDriver driver; public static final String BASE_URL = "http://pet-clinic:8080/"; // public static final String BASE_URL = "http://localhost:8080/"; - public SeleniumBaseTest() throws MalformedURLException { + public SeleniumBaseIT() throws MalformedURLException { // System.setProperty("webdriver.chrome.driver","C:\\Users\\marti\\Downloads\\chromedriver_win32\\chromedriver.exe"); // this.driver = new ChromeDriver(); this.driver = new RemoteWebDriver(new URL("http://selenium:4444/wd/hub"), DesiredCapabilities.firefox());