Javascript NetBeans上的JsTestDriver在断言失败后停止测试
我已经按照在Netbeans上使用JS测试驱动程序设置了JavaScript单元测试。但是,与该教程中的结果不同,断言失败后不会执行更多的测试。我怎样才能改变这种行为 例如,给定此测试文件:Javascript NetBeans上的JsTestDriver在断言失败后停止测试,javascript,netbeans,js-test-driver,Javascript,Netbeans,Js Test Driver,我已经按照在Netbeans上使用JS测试驱动程序设置了JavaScript单元测试。但是,与该教程中的结果不同,断言失败后不会执行更多的测试。我怎样才能改变这种行为 例如,给定此测试文件: test.js文件: AssertionsTestCase = TestCase("AssertionsTestCase"); AssertionsTestCase.prototype.testAlwaysPass = function(){ assertEquals(1, 1); assertE
test.js
文件:
AssertionsTestCase = TestCase("AssertionsTestCase");
AssertionsTestCase.prototype.testAlwaysPass = function(){
assertEquals(1, 1);
assertEquals(2, 2);
};
AssertionsTestCase.prototype.testAlwaysFail1 = function(){
assertEquals(1, 2);
};
AssertionsTestCase.prototype.testAlwaysFail2 = function(){
assertEquals(3, 4);
};
server: http://localhost:42442
load:
- test/lib/jasmine/jasmine.js
- test/lib/jasmine-jstd-adapter/JasmineAdapter.js
- test/unit/*.js
server: http://localhost:4244
load:
- test/lib/jasmine/jasmine.js
- test/lib/jasmine-jstd-adapter/JasmineAdapter.js
- test/unit/*.js
进度条显示50%,(2次测试),应该是33%
jsTestDriver.conf
文件:
AssertionsTestCase = TestCase("AssertionsTestCase");
AssertionsTestCase.prototype.testAlwaysPass = function(){
assertEquals(1, 1);
assertEquals(2, 2);
};
AssertionsTestCase.prototype.testAlwaysFail1 = function(){
assertEquals(1, 2);
};
AssertionsTestCase.prototype.testAlwaysFail2 = function(){
assertEquals(3, 4);
};
server: http://localhost:42442
load:
- test/lib/jasmine/jasmine.js
- test/lib/jasmine-jstd-adapter/JasmineAdapter.js
- test/unit/*.js
server: http://localhost:4244
load:
- test/lib/jasmine/jasmine.js
- test/lib/jasmine-jstd-adapter/JasmineAdapter.js
- test/unit/*.js
我可以通过命令行运行所有测试。(在Windows PowerShell上)。按如下方式运行,失败后测试不会停止运行:
java-jar$env:JSTD\JsTestDriver-1.3.5.jar--tests all--config JsTestDriver.conf
jsTestDriver.conf
文件:
AssertionsTestCase = TestCase("AssertionsTestCase");
AssertionsTestCase.prototype.testAlwaysPass = function(){
assertEquals(1, 1);
assertEquals(2, 2);
};
AssertionsTestCase.prototype.testAlwaysFail1 = function(){
assertEquals(1, 2);
};
AssertionsTestCase.prototype.testAlwaysFail2 = function(){
assertEquals(3, 4);
};
server: http://localhost:42442
load:
- test/lib/jasmine/jasmine.js
- test/lib/jasmine-jstd-adapter/JasmineAdapter.js
- test/unit/*.js
server: http://localhost:4244
load:
- test/lib/jasmine/jasmine.js
- test/lib/jasmine-jstd-adapter/JasmineAdapter.js
- test/unit/*.js
所有三个测试都已运行。似乎在Chrome中工作正常。 关于Firefox,评论中说这不是正确的答案。我已设法使它部分工作。问题是netbeans如何处理失败的测试以及如何启动jstestdriver.jar。我知道这并不能解决问题,但它指向了正确的方向 复制这一点的步骤
/home/{user}/.netbeans/8.2/config/Preferences/org/netbeans/modules/javascript/jstestdriver.properties
通过向jstestdriver.jar--tests all--reset添加参数来编辑location属性。编辑完我的属性后,看起来像这样
location=/home/user/Downloads/jstestdriver-1.3.5.jar--tests all--reset
server.url=http://localhost:42442
strict.mode=false
use.browser.ANDROID\u DEVICE\u CHROME=false
use.browser.ANDROID\u DEVICE\u DEFAULT=false
use.browser.ANDROID\u EMULATOR\u DEFAULT=false
use.browser.Chrome=false
use.browser.Chrome.INTEGRATED=false
use.browser.SL__浏览器_FirefoxBrowser=true
use.browser.SL__Browsers_MozillaBrowser=false
- 从服务重新启动JS测试驱动程序
- 运行测试
在第二次重新启动并运行之后,它应该运行上图所示的所有测试。若您可以在Netbeans中为JS测试驱动程序添加参数--tests all--reset,那个么它应该可以像在Chrome中一样解决这个问题。您是否在其他浏览器中尝试过?因为它是从命令行运行的,所以我假设故障是由netbeans或浏览器引起的。这对您有帮助吗?jasmine--stop on failure=false也许这里的评论可以帮助我认为netbeans测试处理有缺陷,至少在Mocha中是这样。