我刚从JsTestDriver开始,我创建了非常简单的演示代码,以确定我是否正确地配置了我的环境。然而,当火狐(通过JsTestDriver)启动时,大约有40-50%的时间我会收到以下错误:“火狐在启动时意外关闭”。
如果我使用Chrome,是否会出现而不是的错误。
我的环境包括:
我正在执行:
java -jar /home/developer/bin/JsTestDriver.jar --port 9876 --browser /usr/bin/firefox --tests all --testOutput results
我的JsTestDriver配置是:
server: http://localhost:9876
load:
- src/*.js
test:
- test/*.js
timeout: 10源代码(正在测试的代码)是:
Person = function()
{
this.firstName = "";
this.lastName = "";
this.fullName = function()
{
if((this.firstName != "") && (this.lastName != ""))
{
return this.lastName + ", " + this.firstName;
}
var name = this.firstName + " " + this.lastName;
return name.trim();
}
};测试代码(基于JsTestDriver的代码)是:
PersonTest = TestCase("PersonTest");
PersonTest.prototype.testFullName = function()
{
fixture = new Person();
fixture.firstName = "John";
fixture.lastName = "Doe";
assertEquals("Doe, John", fixture.fullName());
};
PersonTest.prototype.testFullName_FirstNameOnly = function()
{
fixture = new Person();
fixture.firstName = "John";
assertEquals("John", fixture.fullName());
};
PersonTest.prototype.testFullName_LastNameOnly = function()
{
fixture = new Person();
fixture.lastName = "Doe"
assertEquals("Doe", fixture.fullName());
};谢谢!
发布于 2012-06-30 01:38:49
您的问题可能在于每次运行测试时都会打开服务器,打开浏览器。我认为一个不太容易出错的解决方案是启动您的服务器,让它捕获一些浏览器,然后继续运行。然后,您可以根据需要在该服务器上运行测试。我们的解决方案包括三个一直运行IE7、IE8、IE9、Firefox和Chrome的虚拟机,我们的Maven构建过程在每次构建时都运行我们的javascript单元测试。此外,确保您始终使用‘-重置’参数以及。它将使您的浏览器保持新鲜。我写了一篇文章,展示了如何将QUnit、Requirejs和代码覆盖与独立于Maven:js-测试驱动程序+qunit+覆盖率+需求的JSTD集成在一起。希望能帮上忙。
https://stackoverflow.com/questions/11201664
复制相似问题