How to run JUnit tests parallel Selenium Grid
<p>I have following problem:</p>

<p>I'm trying to run our selenium tests parallel on our selenium grid configuration, we are using junit as TestFramework. Unfortunatly it doesn't work...
I resetted my branch to show you what the base configuration is.</p>

<pre><code>  public class WebDriverHelpers {

    private WebDriverHelpers() {
    }

    static String iPhoneUserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3";

    /**
     * Creates a WebDriver instance to run the tests locally.
     * 
     * @param browserType
     *            The type of the driver, e.g. Firefox.
     * @return The instance of the driver.
     */
    public static WebDriver getLocalDriver(BrowserType browserType,
            String usProxyUrl) {

        switch (browserType) {
        case CHROME:
           String chromeDir = System.getProperty("user.dir");
           System.setProperty("webdriver.chrome.driver",chromeDir+ "/drivers/chromedriver.exe");
           return new ChromeDriver();
        case FIREFOX:
            String marionetteDir = System.getProperty("user.dir");
            String marionetteDriverLocation = marionetteDir + "/drivers/wires.exe";
            System.setProperty("webdriver.gecko.driver", marionetteDriverLocation);
            return new MarionetteDriver();
        case MOBILE_IPHONE:
            return new FirefoxDriver(getCapabilitiesMobile());
        case INTERNET_EXPLORER:
            return new InternetExplorerDriver();
        case FIREFOX_USPROXY:
            return new FirefoxDriver(getCapabilitiesUsProxy(usProxyUrl));
        case MOBILE_USPROXY:
            return new FirefoxDriver(getCapabilitiesMobileUsProxy(usProxyUrl));
        default:
            throw new UnsupportedOperationException(
                    "The driver for " + browserType + " is not supported.");

        }
    }

    /**
     * Creates a WebDriver instance to run the tests using selenium grid.
     * 
     * @return The instance of the driver.
     */
    public static WebDriver getRemoteDriver(BrowserType browserType,
            String usProxyUrl, String seleniumHubUrl)
                    throws MalformedURLException {

        DesiredCapabilities capabilities = DesiredCapabilities.firefox();

        switch (browserType) {
        case CHROME:
            capabilities = DesiredCapabilities.chrome();
            break;
        case FIREFOX:
            capabilities = DesiredCapabilities.firefox();
            break;
        case MOBILE_IPHONE:
            capabilities = setCapabilitiesMobile(capabilities);
            break;
        case INTERNET_EXPLORER:
            capabilities = DesiredCapabilities.internetExplorer();
            break;
        case FIREFOX_USPROXY:
            capabilities = setCapabilitiesUsProxy(capabilities, usProxyUrl);
            break;
        case MOBILE_USPROXY:
            capabilities = setCapabilitiesMobile(capabilities);
            capabilities = setCapabilitiesUsProxy(capabilities, usProxyUrl);
            break;

        default:
            throw new UnsupportedOperationException(
                    "The driver for " + browserType + " is not supported.");
        }

        return new RemoteWebDriver(new URL(seleniumHubUrl), capabilities);
    }

    private static DesiredCapabilities setCapabilitiesMobile(
            DesiredCapabilities capabilities) {
        FirefoxProfile firefoxProfile = new FirefoxProfile();
        firefoxProfile.setPreference("general.useragent.override",
                iPhoneUserAgent);
        capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
        return capabilities;
    }

    private static DesiredCapabilities setCapabilitiesUsProxy(
            DesiredCapabilities capabilities, String usProxyUrl) {
        org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
        proxy.setHttpProxy(usProxyUrl).setFtpProxy(usProxyUrl)
                .setSslProxy(usProxyUrl);
        capabilities.setCapability(CapabilityType.PROXY, proxy);
        return capabilities;
    }

    private static DesiredCapabilities getCapabilitiesMobile() {
        DesiredCapabilities capabilities = DesiredCapabilities.firefox();
        return setCapabilitiesMobile(capabilities);
    }

    private static DesiredCapabilities getCapabilitiesUsProxy(
            String usProxyUrl) {
        DesiredCapabilities capabilities = DesiredCapabilities.firefox();
        return setCapabilitiesUsProxy(capabilities, usProxyUrl);
    }

    private static DesiredCapabilities getCapabilitiesMobileUsProxy(
            String usProxyUrl) {
        DesiredCapabilities capabilities = DesiredCapabilities.firefox();
        capabilities = setCapabilitiesMobile(capabilities);
        capabilities = setCapabilitiesUsProxy(capabilities, usProxyUrl);
        return capabilities;
    }

}
</code></pre>

<p>These are the methods, which read our config file and provide the specific webdriver.</p>

<pre><code>    @BeforeClass
    public static void classSetUp() {

        readEnvironmentConfigFromFile(getConfigProperties());
        setEnvironmentUrls();
    }

    /**
     * The JUnit framework calls this method every time before it executes a
     * test method.
     */
    @Before
    public void setUp() throws MalformedURLException {

        backupOldScreenshots();

        /**
         * Use local driver to run the tests on your local machine. / Use remote
         * driver to run the tests via selenium grid.
         */
        if (isRemoteTest) {
            driver = WebDriverHelpers.getRemoteDriver(browserType, usProxyUrl,
                    seleniumHubUrl);
        } else {
            // Note: Firefox is always used for local tests
            driver = WebDriverHelpers.getLocalDriver(browserType, usProxyUrl);
        }

        initializeBrowser();
    enter code here
        page = new StartPage(driver);
    }

    protected void initializeBrowser() {
        driver.manage().deleteAllCookies();
        try {
            driver.manage().window().maximize();
        } catch (Exception e) {
            System.out.println("Could not maximize window.");
        }
    }

This is how one of our testsuites looks like

        @RunWith(Suite.class)
    @Suite.SuiteClasses({ a.class, b.class,
            c.class })
    public class AllTests {

    }
</code></pre>

<p>Do you have clues :-) </p>