1

我在运行业力测试时遇到问题。当我“业力开始”时,它说“执行 0 次成功 0 次”,但我有测试。业力只是看不到他们。但它运行文件,因为它进入了描述块。有什么想法,可能是什么原因造成的?这是我的因果报应。

// Testacular configuration

// base path, that will be used to resolve files and exclude
basePath = '';

frameworks = ['jasmine'];

// list of files / patterns to load in the browser
files = [
  JASMINE,
  JASMINE_ADAPTER,
  REQUIRE,
  REQUIRE_ADAPTER,

  // Add right away, lets include those
  'src/main/webapp/tools/js/vendor/shim/**/*.js',

  'src/main/webapp/tools/test/require-runner.js',

  // Test dependencies
  'src/main/webapp/tools/js/vendor/angular/angular-1.0.7.js',
  'src/main/webapp/tools/test/vendor/angular-*.js',

  // All app stuff that can be required!
  { pattern: 'src/main/webapp/tools/js/**/*', included : false },

  // All tests
  { pattern: 'src/main/webapp/tools/test/spec/**/*.test.js', included : false }

];


// list of files to exclude
exclude = [];

preprocessors = {
  'src/main/webapp/app/!(vendor)/**/*.js' : 'coverage'
};

// possible values: 'dots', 'progress', 'junit', 'teamcity'
// CLI --reporters progress
reporters = [ 'progress', 'junit' ];

coverageReporter = {
  type: 'cobertura',
  dir : 'coverage/'
};

// web server port
port = 1317;

// cli runner port
runnerPort = 1318;

// If browser does not capture in given timeout [ms], kill it
// CLI --capture-timeout 5000
captureTimeout = 5000;

// report which specs are slower than 500ms
// CLI --report-slower-than 500
reportSlowerThan = 500;

// enable / disable colors in the output (reporters and logs)
colors = true;

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel = LOG_INFO;

// enable / disable watching file and executing tests whenever any file changes
autoWatch = true;

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari
// - PhantomJS
browsers = [ 'PhantomJS' ];

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = false;

这是我的要求跑步者

var allTestFiles = [],
    TEST_REGEXP  = /^.*spec\/.*test.js/,
    file;

// Build test files
for (file in window.__karma__.files) {
  if (window.__karma__.files.hasOwnProperty(file)) {
    if (TEST_REGEXP.test(file)) {
      allTestFiles.push(file);
    }
  }
}

require.config({
  // Testacular serves files under /base, which is the basePath from your config file
  baseUrl: '/base/src/main/webapp/tools',

  paths : {

    config      : 'config',

    // Angular specific libraries
    angular      : 'js/vendor/angular/angular-boilerplate',
    _ng          : 'js/vendor/angular/angular-1.0.7',
    _ngCookies   : 'js/vendor/angular/angular-cookies-1.0.7',

    // jQuery specific libraries
    jquery      : 'js/vendor/jquery'

  },

  // Shim. Things that do not support AMD
  shim : {
    _ng: {
      deps       : [ 'jquery' ],
      exports : 'angular'
    },
    _ngCookies   : [ '_ng' ]
  },

  // dynamically load all test files
  deps: allTestFiles,

  // we have to kick of jasmine, as it is asynchronous
  callback: window.__karma__.start
});
4

1 回答 1

2

找到了我的问题的解决方案:“我在控制台中没有输出。但我发现了错误。我添加了带有占位符的角度脚本,并且还加载了 angular-scenario.js。在我删除之后这个文件,我的测试成功执行了。”

我不小心将 angular-scenario 与其他文件一起加载,这导致了问题。删除后,一切都像魅力一样。

可以在 GitHub 业力问题中找到主题

于 2013-08-19T08:35:05.097 回答