Main Page

From JavaScript JUnit Bridge (inactive) Wiki
Jump to: navigation, search

The JS-JUnit-Bridge enables execution of JavaScript tests inside the junit framework without the need to write test methods in junit.

In detail, it is a junit runner, that bridge the run and results of js-unit-test to junit. The runner can use different parser to support different JavaScript unit testing frameworks. Currently only qunit is supported but other could be added easily (add a feature-request).

Motivation

The background for writing this bridge was the need to run complex javascript tests (with acceptable performance) inside the maven life-cycle, so the goal was js test automation for local development and also continues integration scenarios in standalone and/or java/groovy projects.

Getting Started

1. We need a valid Version of the JS-JUnit-Bridge. Let's use Maven for this ...

...
    <!-- js-junit-bridge maven repository -->
    <repository>
        <id>evolvis-repository</id>
        <name>evolvis Maven2 Repository</name>
        <url>http://maven-repo.evolvis.org/releases</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
...
...
    <!-- js-junit-bridge dependancy -->
    <dependency>
        <groupId>de.tarent.junit</groupId>
        <artifactId>js-junit-bridge</artifactId>
        <version>0.3.0</version>
        <scope>test</scope>
    </dependency>
...

2. Create a 'index.html' with included JS-Unit-Tests under '/path/to/test/index.html'

3. Write a JUnit-Test and use the 'JsJUnitBridgeRunner', '@JsJUnitBridgeConfiguration' and JS-UnitParser for configuration

@RunWith(JsJUnitBridgeRunner.class)
@JsJUnitBridgeConfiguration(
	uri = "file://path/to/test/index.html",
	resultParser = QUnitParser.class,
	localWebDriverConfigurations = {
			@WebDriverConfiguration(driver = FirefoxDriver.class)
	}
)
public class LocalTest {}

4. Thats it.