【发布时间】:2014-01-11 17:46:48
【问题描述】:
我正在尝试使用 Resharper 8.0.2 让 yeoman 生成的单元测试在 Visual Studio 中运行。
使用 yeoman,如果你只是生成一个控制器,你会得到这样的东西:
'use strict';
describe('Controller: MainCtrl', function () {
// load the controller's module
beforeEach(module('angularYeomanTestApp'));
var MainCtrl,
scope;
// Initialize the controller and a mock scope
beforeEach(function() {
inject(function($controller, $rootScope) {
scope = $rootScope.$new();
MainCtrl = $controller('MainCtrl', {
$scope: scope
});
})
});
it('should attach a list of awesomeThings to the scope', function () {
expect(scope.awesomeThings.length).toBe(3);
});
});
我已经把this post的知识转移了,因为yeoman在inject语句之前没有生成匿名函数。
问题是我总是在每个测试中遇到错误,例如:
Inconclusive: Test wasn't run
Resharper 配置为使用 chrome 浏览器运行测试,并且 jasmine 在打开时似乎已正确包含在测试页面中,但测试页面为空!
使用 karma 运行测试,例如咕噜测试确实有效!
感谢您的帮助!
PS.:我正在使用:Visual-Studio-2013、Resharper 8.0.2、angularjs 1.2.6
【问题讨论】:
-
这是您的完整测试吗?您是否包含了对所有需要的 js 文件的引用?使用 resharper 为了运行测试,您必须在包含测试之前引用所有 js 文件。如果您拖动它们,vs 将为您创建它们。类似 ///
-
是的,这是完整的测试。 Karma 配置为将大约 15 个文件或其他内容加载到浏览器中。我应该手动添加它们吗?
标签: unit-testing angularjs jasmine visual-studio-2013 resharper-8.0