我试图单独运行 com.github.klieber.phantomjs-maven-plugin ,然后尝试使用 com.github.searls.jasmine-maven-plugin
最终目标是能够在maven中运行Javascripts测试,然后在Jenkins中运行。
但我总是有同样的错误:
//MVC Action to download the correct file From our Content directory
public ActionResult GetFile(string name) {
string path = this.Server.MapPath("~/Content/" + name);
byte[] file = System.IO.File.ReadAllBytes(path);
return this.File(file, "html/text");
}
我用
创建了一个maven项目 [ERROR] Failed to execute goal com.github.klieber:phantomjs-maven-plugin:0.7:install (default) on project my-jasmine-project: Execution default of goal com.gith
ub.klieber:phantomjs-maven-plugin:0.7:install failed: Unable to load the mojo 'install' (or one of its required components) from the plugin 'com.github.klieber:
phantomjs-maven-plugin:0.7': com.google.inject.ProvisionException: Guice provision errors:
[ERROR]
[ERROR] 1) Could not find a suitable constructor in com.github.klieber.phantomjs
.mojo.InstallPhantomJsMojo. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
[ERROR] at com.github.klieber.phantomjs.mojo.InstallPhantomJsMojo.class(Unknown
Source)
[ERROR] while locating com.github.klieber.phantomjs.mojo.InstallPhantomJsMojo
[ERROR] at ClassRealm[plugin>com.github.klieber:phantomjs-maven-plugin:0.7, parent: sun.misc.Launcher$AppClassLoader@f4a24a]
[ERROR] while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=com.github.klieber:phantomjs-maven-plugin:0.7:install)
[ERROR]
[ERROR] 1 error
[ERROR] role: org.apache.maven.plugin.Mojo
[ERROR] roleHint: com.github.klieber:phantomjs-maven-plugin:0.7:install
这是我尝试只安装Phantom JS的pom
mvn archetype:generate -DarchetypeGroupId=com.github.searls
-DarchetypeArtifactId=jasmine-archetype
-DarchetypeVersion=RELEASE
-DjasminePluginVersion=2.1
-DgroupId=com.acme
-DartifactId=my-jasmine-project
-Dversion=0.0.1-SNAPSHOT
你能告诉我我做错了吗?
提前致谢,
答案 0 :(得分:2)
我认为您的问题与此问题相同:https://github.com/klieber/phantomjs-maven-plugin/issues/34
解决方案:确保您使用的是Maven 3.1或更高版本。
答案 1 :(得分:1)
我找到了另一个在maven中运行Javascripts测试的解决方案,然后在Jenkins中
以下是我在POM中使用它的方法:
<!-- Install phantom JS binaries. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.phantomjs</groupId>
<artifactId>phantomjs</artifactId>
<version>${phantomjs.version}</version>
<type>${phantomjs.packaging}</type>
<classifier>${phantomjs.classifier}</classifier>
<!-- Unpack the artifact in a directory at the same level than
the build directory. -->
<outputDirectory>${project.build.directory}/..</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
根据平台,我激活不同的配置文件,以便下载正确的工件(用于Windows的工具或用于我们Jenkins运行的Linux工具。希望它有帮助!:)
<!-- PhantomJS for Windows -->
<profile>
<id>phantomJS-windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<phantomjs.classifier>windows</phantomjs.classifier>
<phantomjs.bin>phantomjs.exe</phantomjs.bin>
<phantomjs.packaging>zip</phantomjs.packaging>
<test.script.ext>bat</test.script.ext>
</properties>
</profile>
<!-- XXX: Jenkins instance runs on Linux 64 bits. -->
<!-- 64 bits. -->
<profile>
<id>phantomJS-bca-jenkins</id>
<activation>
<property>
<name>sun.arch.data.model</name>
<value>64</value>
</property>
</activation>
<properties>
<phantomjs.classifier>linux-x86_64</phantomjs.classifier>
<phantomjs.bin>bin/phantomjs</phantomjs.bin>
<phantomjs.packaging>tar.bz2</phantomjs.packaging>
<test.script.ext>sh</test.script.ext>
</properties>
</profile>