我试图使用1.6插件将Karma与Maven集成,但是它失败了,并声明:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-karma-plugin:1.6:start (default) @ amm ---
[INFO] Executing Karma Test Suite ...
cmd /C C:\Dev\Workspaces\projectname\subname/src/main/webapp/node_modules/.bin/kar
ma start C:\Dev\Workspaces\projectname\subname\src\main\webapp\karma.conf.js --bro
wsers Chrome, Firefox --single-run --no-auto-watch --colors true
The system cannot find the path specified.以下是maven pom.xml中的设置
<plugin>
<groupId>com.kelveden</groupId>
<artifactId>maven-karma-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
</executions>
<configuration>
<karmaExecutable>${ammWorkspaceDir}/src/main/webapp/node_modules/.bin/karma</karmaExecutable>
<configFile>${ammWorkspaceDir}/src/main/webapp/karma.conf.js</configFile>
<browsers>Chrome, Firefox</browsers>
<autoWatch>false</autoWatch>
<singleRun>true</singleRun>
<colors>true</colors>
<skipKarma>false</skipKarma>
<skipTests>false</skipTests>
<karmaFailureIgnore>false</karmaFailureIgnore>
<!-- <reporters>dots,junit</reporters> -->
</configuration>
</plugin>我使用cmd dir检查了node_modules文件夹是否包含.bin文件夹,但它只包含:
karma
karma-chrome-launcher
karma-firefox-launcher
karm-jasmine.bin文件夹在哪里?注意,我可以运行所有的普通测试,但是我必须导航到karma.conf.js文件要运行它们的位置,并且可以使用karma start运行测试(它们都通过)。
那为什么会失败呢?业力是否安装在错误的地方?node和这样的System variable应该存在吗?
谢谢
发布于 2014-08-14 18:39:51
我解决了问题。造成建造问题的是业力node_modules干扰建造的事实。为了解决这个问题,我必须从node_modules文件夹中删除webapp,并将其移动到项目的根目录和karma.conf.js文件中。
这是第一部分-第二部分是使用这个命令在全球范围内安装业力:
npm install -g karma && npm install -g karma-cli通过这样做,你应该能够从任何地方运行业力,但对我来说不是这样,我仍然不知道为什么(精心设计任何人?)最后一部分在实际maven pom.xml中。
<plugin>
<groupId>com.kelveden</groupId>
<artifactId>maven-karma-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
</executions>
<configuration>
<configFile>karma.conf.js</configFile>
<browsers>Chrome</browsers>
<autoWatch>false</autoWatch>
<singleRun>true</singleRun>
<colors>true</colors>
<skipKarma>false</skipKarma>
<skipTests>false</skipTests>
<karmaFailureIgnore>false</karmaFailureIgnore>
</configuration>
</plugin>上面的关键点是,我没有在这里包含<karmaExecutable>命令,因为如果您包含它,那么它就会中断--通过将它排除在外,它将转向全局业力安装,在Maven构建中运行测试。这对我有用-希望它对你有用。
https://stackoverflow.com/questions/25288601
复制相似问题