Some valid examples:
- *Web driver capabilities used to initialize a DesiredCapabilities instance when creating a web driver.
- * - *Capabilities value can be either a String, a List, or a Map.
- * - *Example:
- *- * <webDriverCapabilities> - * <capability> - * <name>phantomjs.binary.path</name> - * <value>/opt/phantomjs/bin/phantomjs</value> - * </capability> - * <capability> - * <name>phantomjs.cli.args</name> - * <list> - * <value>--disk-cache=true</value> - * <value>--max-disk-cache-size=256</value> - * </list> - * </capability> - * <capability> - * <name>proxy</name> - * <map> - * <httpProxy>myproxyserver.com:8000</httpProxy> - * </map> - * </capability> - * </webDriverCapabilities> - *- * - * @since 1.3.1.1 - */ - @Parameter - protected List
Determines the browser and version profile that HtmlUnit will simulate. This setting does nothing if the plugin is configured not to use HtmlUnit. - * This maps 1-to-1 with the public static instances found in {@link com.gargoylesoftware.htmlunit.BrowserVersion}.
- * - *Some valid examples: CHROME, FIREFOX_17, INTERNET_EXPLORER_9, INTERNET_EXPLORER_10
- * - * @since 1.1.0 - */ - @Parameter(defaultValue="FIREFOX_17") - protected String browserVersion; - - /** - *Determines the format that jasmine:test will print to console.
- *Valid options:
- *JavaScript sources (typically vendor/lib dependencies) that need to be loaded
* before other sources (and specs) in a particular order. Each source will first be
@@ -250,14 +174,6 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin
@Parameter(defaultValue="ManualSpecRunner.html")
protected String manualSpecRunnerHtmlFileName;
- /**
- * The name of the generated JUnit XML report.
- *
- * @since 1.1.0
- */
- @Parameter(defaultValue="TEST-jasmine.xml")
- protected String junitXmlReportFileName;
-
/**
* The name of the directory the specs will be deployed to on the server.
*
@@ -282,15 +198,6 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin
@Parameter(defaultValue="${project.build.sourceEncoding}")
protected String sourceEncoding;
- /**
- * Keep the server alive after the jasmine:test
goal exists.
- * Useful if you need to run further analysis on your tests, like collecting code coverage.
- *
- * @since 1.3.1.0
- */
- @Parameter(property="keepServerAlive", defaultValue="false")
- protected boolean keepServerAlive;
-
/**
*
Allows specifying which source files should be included and in what order.
*@@ -376,16 +283,16 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin @Parameter(property="jasmine.uriScheme", defaultValue="http") protected String uriScheme; - /** - *Not used by the
- * - *jasmine:bdd
goal.The
- * - * @since 1.3.1.4 - */ - @Parameter(property="jasmine.serverHostname", defaultValue = "localhost") - protected String serverHostname; + /** + *jasmine:test
goal to specify hostname where the server is running. Useful when using - * the RemoteWebDriver.Not used by the
+ * + *jasmine:bdd
goal.The
+ * + * @since 1.3.1.4 + */ + @Parameter(property="jasmine.serverHostname", defaultValue = "localhost") + protected String serverHostname; /** *jasmine:test
goal to specify hostname where the server is running. Useful when using + * the RemoteWebDriver.Determines the strategy to use when generation the JasmineSpecRunner. This feature allows for custom diff --git a/src/main/java/com/github/searls/jasmine/mojo/PhantomJsOptions.java b/src/main/java/com/github/searls/jasmine/mojo/PhantomJsOptions.java new file mode 100644 index 000000000..422c2c3e0 --- /dev/null +++ b/src/main/java/com/github/searls/jasmine/mojo/PhantomJsOptions.java @@ -0,0 +1,76 @@ +package com.github.searls.jasmine.mojo; + +import com.github.klieber.phantomjs.locate.PhantomJsLocatorOptions; + +import java.io.File; + +public class PhantomJsOptions implements PhantomJsLocatorOptions { + + private static final String DEFAULT_PHANTOMJS_VERSION = "2.0.0"; + private static final String DEFAULT_OUTPUT_DIRECTORY = "target/phantomjs"; + + private Source source = Source.REPOSITORY; + + private String version; + private boolean checkSystemPath; + private boolean enforceVersion; + + private String baseUrl; + private File outputDirectory; + + public PhantomJsOptions() { + this.source = Source.REPOSITORY; + this.version = DEFAULT_PHANTOMJS_VERSION; + this.checkSystemPath = true; + this.enforceVersion = true; + this.outputDirectory = new File(DEFAULT_OUTPUT_DIRECTORY); + } + + public Source getSource() { + return source; + } + + public void setSource(Source source) { + this.source = source; + } + + public boolean isCheckSystemPath() { + return checkSystemPath; + } + + public void setCheckSystemPath(boolean checkSystemPath) { + this.checkSystemPath = checkSystemPath; + } + + public boolean isEnforceVersion() { + return enforceVersion; + } + + public void setEnforceVersion(boolean enforceVersion) { + this.enforceVersion = enforceVersion; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getBaseUrl() { + return baseUrl; + } + + public void setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + } + + public File getOutputDirectory() { + return outputDirectory; + } + + public void setOutputDirectory(File outputDirectory) { + this.outputDirectory = outputDirectory; + } +} diff --git a/src/main/java/com/github/searls/jasmine/mojo/TestMojo.java b/src/main/java/com/github/searls/jasmine/mojo/TestMojo.java index d7d1c3d47..dc26c4aa5 100644 --- a/src/main/java/com/github/searls/jasmine/mojo/TestMojo.java +++ b/src/main/java/com/github/searls/jasmine/mojo/TestMojo.java @@ -1,17 +1,7 @@ package com.github.searls.jasmine.mojo; -import java.io.File; -import java.net.URL; - -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.ResolutionScope; -import org.eclipse.jetty.server.Server; -import org.openqa.selenium.WebDriver; - +import com.github.klieber.phantomjs.locate.PhantomJsLocatorOptions; +import com.github.klieber.phantomjs.locate.RepositoryDetails; import com.github.searls.jasmine.NullLog; import com.github.searls.jasmine.driver.WebDriverFactory; import com.github.searls.jasmine.format.JasmineResultLogger; @@ -22,16 +12,174 @@ import com.github.searls.jasmine.runner.SpecRunnerExecutor; import com.github.searls.jasmine.server.ResourceHandlerConfigurator; import com.github.searls.jasmine.server.ServerManager; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.jetty.server.Server; +import org.openqa.selenium.WebDriver; + +import javax.inject.Inject; +import java.io.File; +import java.net.URL; +import java.util.Collections; +import java.util.List; +import java.util.Properties; /** - * Execute specs using Selenium Web Driver. Uses HtmlUnitDriver for head-less execution by default. + * Execute specs using Selenium Web Driver. Uses PhantomJsDriver for head-less execution by default. */ @Mojo(name="test",defaultPhase=LifecyclePhase.TEST,requiresDependencyResolution = ResolutionScope.TEST) public class TestMojo extends AbstractJasmineMojo { + /** + * Determines the Selenium WebDriver class we'll use to execute the tests. See the Selenium documentation for more details. + * The plugin uses HtmlUnit by default. + * + *
Some valid examples:
+ *
Web driver capabilities used to initialize a DesiredCapabilities instance when creating a web driver.
+ * + *Capabilities value can be either a String, a List, or a Map.
+ * + *Example:
+ *+ * <webDriverCapabilities> + * <capability> + * <name>phantomjs.binary.path</name> + * <value>/opt/phantomjs/bin/phantomjs</value> + * </capability> + * <capability> + * <name>phantomjs.cli.args</name> + * <list> + * <value>--disk-cache=true</value> + * <value>--max-disk-cache-size=256</value> + * </list> + * </capability> + * <capability> + * <name>proxy</name> + * <map> + * <httpProxy>myproxyserver.com:8000</httpProxy> + * </map> + * </capability> + * </webDriverCapabilities> + *+ * + * @since 1.3.1.1 + */ + @Parameter + protected List
Determines the browser and version profile that HtmlUnit will simulate. This setting does nothing if the plugin is configured not to use HtmlUnit. + * This maps 1-to-1 with the public static instances found in {@link com.gargoylesoftware.htmlunit.BrowserVersion}.
+ * + *Some valid examples: CHROME, FIREFOX_17, INTERNET_EXPLORER_9, INTERNET_EXPLORER_10
+ * + * @since 1.1.0 + * @deprecated Use the webDriverCapabilities parameter instead. + */ + @Parameter(defaultValue="FIREFOX_17") + @Deprecated + protected String browserVersion; + + /** + *Determines the format that jasmine:test will print to console.
+ *Valid options:
+ *Configure which version of PhantomJS should be used and how it should be found. The core of the + * phantomjs-maven-plugin is used to provide this + * functionality and this parameter should match the configuration of the + * phantomjs-maven-plugin install goal.
+ * + *Default Options:
+ *+ * <phantomjs> + * <version>2.0.0</version> + * <checkSystemPath>true</checkSystemPath> + * <enforceVersion>true</enforceVersion> + * <source>REPOSITORY</source> + * <baseUrl></baseUrl> + * <outputDirectory>target/phantomjs</outputDirectory> + * </phantomjs> + *+ * + * @since 2.0 + */ + @Parameter(property = "phantomjs", defaultValue = "${phantomJs}") + protected PhantomJsOptions phantomjs; + + /** + * The name of the generated JUnit XML report. + * + * @since 1.1.0 + */ + @Parameter(defaultValue="TEST-jasmine.xml") + protected String junitXmlReportFileName; + + /** + * Keep the server alive after the
jasmine:test
goal exists.
+ * Useful if you need to run further analysis on your tests, like collecting code coverage.
+ *
+ * @since 1.3.1.0
+ */
+ @Parameter(property="keepServerAlive", defaultValue="false")
+ protected boolean keepServerAlive;
+
+ @Parameter(
+ defaultValue = "${repositorySystemSession}",
+ readonly = true
+ )
+ private RepositorySystemSession repositorySystemSession;
+
+ @Parameter(
+ defaultValue = "${project.remoteProjectRepositories}",
+ readonly = true
+ )
+ private List