Skip to content

Commit

Permalink
Change how we run the htmlrunner self tests
Browse files Browse the repository at this point in the history
Rather than being parameterized, we read a system property
(defaulting to chrome) and use that. This plays nicely
with the way that Buck works, and allows us to parrlelise
test runs more efficiently.
  • Loading branch information
shs96c committed Oct 7, 2016
1 parent bf47492 commit 7b3a247
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 164 deletions.
2 changes: 1 addition & 1 deletion java/client/test/com/thoughtworks/selenium/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ java_library(
'//third_party/java/servlet:servlet-api',
],
visibility = [
'//java/server/test/org/openqa/selenium/server/htmlrunner:htmlrunner',
'//java/server/test/org/openqa/selenium/server/htmlrunner:',
],
)
24 changes: 19 additions & 5 deletions java/server/test/org/openqa/selenium/server/htmlrunner/BUCK
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
browsers = {'firefox': '*firefox', 'chrome': '*googlechrome'}
for browser in browsers.keys():
java_test(
name = 'htmlrunner-' + browser,
srcs = ['CoreSelfTest.java'],
vm_args = ["-Dselenium.browser=%s" % browsers[browser]],
deps = [
':tests',
'//java/client/src/org/openqa/selenium:selenium',
'//java/client/test/com/thoughtworks/selenium:tests',
'//java/client/test/org/openqa/selenium/environment:environment',
'//java/server/src/org/openqa/selenium/server/htmlrunner:htmlrunner',
'//third_party/java/guava:guava',
'//third_party/java/junit:junit',
],
)

java_test(
name = 'htmlrunner',
srcs = glob(['*.java']),
name ='tests',
srcs = glob(['*UnitTest.java']),
deps = [
'//java/client/src/org/openqa/selenium:selenium',
'//java/client/test/com/thoughtworks/selenium:tests',
'//java/client/test/org/openqa/selenium/environment:environment',
'//java/server/src/org/openqa/selenium/server/htmlrunner:htmlrunner',
'//third_party/java/guava:guava',
'//third_party/java/junit:junit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@
package org.openqa.selenium.server.htmlrunner;

import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeNotNull;

import com.google.common.base.StandardSystemProperty;
import com.google.common.collect.ImmutableSortedSet;

import com.thoughtworks.selenium.testing.SeleniumAppServer;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.openqa.selenium.Platform;
import org.openqa.selenium.environment.webserver.AppServer;
import org.openqa.selenium.os.CommandLine;

Expand All @@ -39,24 +37,37 @@
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;

@RunWith(Parameterized.class)
public class CoreSelfTest {

private final String browser;
private static AppServer server;
private String browser;
private AppServer server;

public CoreSelfTest(String browser) {
this.browser = browser;
@Before
public void detectBrowser() {
browser = System.getProperty("selenium.browser", "*googlechrome");

switch (browser) {
case "*firefox":
assumeNotNull(CommandLine.find("geckodriver"));
break;

case "*googlechrome":
assumeNotNull(CommandLine.find("chromedriver"));
break;

default:
assumeFalse("No known driver able to be found", false);
}
}

@BeforeClass
public static void startTestServer() {
@Before
public void startTestServer() {
server = new SeleniumAppServer();
server.start();
}

@AfterClass
public static void stopTestServer() {
@After
public void stopTestServer() {
server.stop();
}

Expand Down Expand Up @@ -84,29 +95,4 @@ public void executeTests() throws IOException {

assertEquals("PASSED", result);
}

@Parameterized.Parameters
public static Iterable<String> parameters() {
ImmutableSortedSet.Builder<String> browsers = ImmutableSortedSet.naturalOrder();

if (CommandLine.find("chromedriver") != null) {
browsers.add("*googlechrome");
}

if (CommandLine.find("geckodriver") != null) {
browsers.add("*firefox");
}

switch (Platform.getCurrent().family()) {
case MAC:
// browsers.add("*safari");
break;

case WINDOWS:
browsers.add("*MicrosoftEdge");
break;
}

return browsers.build();
}
}

This file was deleted.

0 comments on commit 7b3a247

Please sign in to comment.