我们还在研究测试我们的网络应用程序前端的方法。
目前我们有一些使用无头浏览器 phantomJS 的测试。测试是用 JavaScript 编写的,如下所示:
(function () {
// require is part of phantom API
var userName,
page = require('webpage').create();
page.open("http://<url of page to test>", function (status) {
if (status !== 'success') {
phantom.exit(1);
} else {
// get the text of the DOM element that displays the user name
userName = page.evaluate(function() {
return document.getElementById('userName').innerText;
});
if (userName !=== 'Guest') {
phantom.exit(1);
}
phantom.exit(); // Success!
}
});
})();
我们使用这样的命令从 Jenkins 调用它(其中assert_Username_EqualsGuest.js包含上面的 JavaScript):
phantomJS.exe assert_Username_EqualsGuest.js
我们也有类似的用 powerscript 编写的测试,它使用 System.Net.WebClient 类从 Web 服务器下载动态资源,断言返回的内容,并记录响应时间以跟踪服务器性能随时间的变化。也被詹金斯解雇了。
所以这个答案只是为了让你知道我们目前在做什么,但我们也在研究更好的方法。我很想听听其他人在做什么。