1

我正在尝试使用 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);
  });
});

我已经转移了这篇文章的知识,因为 yeoman 在注入语句之前不会生成匿名函数。

问题是我总是在每个测试中遇到错误,例如:

Inconclusive: Test wasn't run

Resharper 被配置为使用 chrome 浏览器运行测试,并且 jasmine 在打开时似乎已正确包含在测试页面中,但测试页面为空!

使用例如 grunt test 运行带有 karma 的测试确实有效!

感谢帮助!

PS.:我正在使用:Visual-Studio-2013,Resharper 8.0.2,angularjs 1.2.6

4

1 回答 1

0

业力和重塑者彼此无关。您不必运行或安装 karma 即可运行 Resharper 测试。对于更清晰的测试,您必须拥有,正如我在上面的评论中指出的那样,您需要在每个测试文件中作为“参考”包含所有文件。

于 2013-12-23T15:36:20.557 回答