如果任何一个测试失败,则如何停止茉莉单位测试



我写了以上500个单位测试方法。当我给出ng test命令时。它开始测试所有500种方法。

如果任何测试用例失败,它将不会停止,并且仍然继续执行所有方法。因此,我需要等待更多时间才能再次重新运行单元测试。

我知道我们可以通过使用ng test命令进行ctr+c并再次重新运行单元测试。这样,也需要太多时间。

因此,如果任何一个测试失败了,是否可以停止(不存在(单位测试?

如果要从所有测试用例中排除文件。尝试在CLI配置文件中添加"排除"部分。

src/tsconfig.app.json: 

在此处显示:

{
  "compilerOptions": {
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es2016",
      "dom"
    ],
    "outDir": "../out-tsc/app",
    "target": "es5",
    "module": "es2015",
    "baseUrl": "",
    "types": []
  },
  "exclude": [
    "test.ts",
    "filename.spec.ts"
  ]
}

另一种方法是在jasmine库中使用fdescribe。它与Jasmine describe函数完全相同,除了使用此功能Karma(如果您使用Karma(仅执行fdescribe块并忽略所有describe块,例如:

fdescribe('this block will executed' , async()=>{ 
 ....
 it('only this method will during tests', ()=>{
    expect(1).toEqual(1);
 });
...
describe('this block not executed' ()=>{
   .....
}

当测试完成时,您可以简单地使用describe

重新校准fdescribe功能