Skip to content
Permalink
Browse files

Add doSetUp() method so that the set up of the tests can be overridden.

  • Loading branch information...
stiemannkj1 committed Jul 20, 2016
1 parent 13b3b8b commit 2919b56972daa0b960d86573cd52b516884d0cad
@@ -15,7 +15,6 @@
*/
package com.liferay.faces.test.selenium;

import org.junit.runner.Description;
import org.junit.runner.Result;
import org.junit.runner.notification.RunListener;

@@ -28,20 +27,7 @@
@Override
public void testRunFinished(Result result) throws Exception {

// When the browser is phantomjs or chrome, WebDriver.close() does not quit the browser (like it is supposed to
// https://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebDriver.html#quit%28%29), so we
// use WebDriver.quit() instead.
Browser.getInstance().quit();
IntegrationTesterBase.doTearDown();
super.testRunFinished(result);
}

@Override
public void testRunStarted(Description description) throws Exception {

super.testRunStarted(description);

if (!"tomcat".equals(TestUtil.CONTAINER)) {
TestUtil.signIn();
}
}
}
@@ -16,27 +16,16 @@
package com.liferay.faces.test.selenium;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Before;


/**
* @author Kyle Stiemann
*/
public abstract class IntegrationTesterBase {

/**
* {@link TestSuiteListener#testRunStarted()} is used to sign in to the container when the tests are run with the
* maven-surefire-plugin. However, {@link TestSuiteListener#testRunStarted()} is not called when the tests are not
* run with the maven-surefire-plugin (i.e. when the tests are run from an IDE). So when the tests are run from an
* IDE, it is necessary to sign in to the container before each test class is run.
*/
@BeforeClass
public static void setUp() {

if (!TestUtil.RUNNING_WITH_MAVEN_SUREFIRE_PLUGIN && !TestUtil.CONTAINER.equals("tomcat")) {
TestUtil.signIn();
}
}
// Private Static Data Members
private static boolean setUp = false;

/**
* {@link TestSuiteListener#testRunFinished()} is used to shut down the browser/webDriver when the tests are run
@@ -48,12 +37,30 @@ public static void setUp() {
public static void tearDown() {

if (!TestUtil.RUNNING_WITH_MAVEN_SUREFIRE_PLUGIN) {
doTearDown();
}
}

// When the browser is phantomjs or chrome, WebDriver.close() does not quit the browser (like it is
// supposed to
// https://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebDriver.html#quit%28%29),
// so we use WebDriver.quit() instead.
Browser.getInstance().quit();
protected static void doTearDown() {

// When the browser is phantomjs or chrome, WebDriver.close() does not quit the browser (like it is
// supposed to
// https://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebDriver.html#quit%28%29),
// so we use WebDriver.quit() instead.
Browser.getInstance().quit();
}

@Before
public final void setUp() {

if (!setUp) {

doSetUp();
setUp = true;
}
}

protected void doSetUp() {
TestUtil.signIn(Browser.getInstance());
}
}
@@ -109,9 +109,8 @@ public static String getSystemPropertyOrDefault(String propertyName, String defa
return propertyValue;
}

/* package-private */ static void signIn() {
public static void signIn(Browser browser) {

Browser browser = Browser.getInstance();
browser.get(SIGN_IN_URL);
browser.waitForElementPresent(loginXpath);

0 comments on commit 2919b56

Please sign in to comment.
You can’t perform that action at this time.