私はUnit Testing in Angular2を初めて使用しています。コード範囲がangular-cli
のkarma
の設定があります。私はng-testコマンドを実行し、コードカバレッジレポートを開いた。私は1x
、3x
などと、そのカバレッジレポートのコード行番号を見ました。私のカバレッジレポートイメージを見つけてください。Angular2ユニットテストのカルマコードカバレッジレポートでは、1x 3xなどは何を意味しますか?
は、ここに私のテストケースコードapp.component.spec.ts
/* tslint:disable:no-unused-variable */
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent',() => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
});
});
it('should create the app', async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app works!'`, async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app works!');
}));
it('should render title in a h1 tag', async(() => {
let fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
let compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('app works!');
}));
});
私は私のコードのレポートでその1x,2x,3x
などの重要性が何であるかを理解していなかったです。その重要性を知る上で助けてください。
答えてくれてありがとう@echonax。あなたが忘れてしまった情報が他にもある場合は、私を共有してください。そうでない場合は、あなたの答えでそれを詳述することができます。もう一度、ありがとうございます。あなたの答えを受け入れる。 –
@IsettyRavitejakumarあなたの質問を更新したので、私は自分の答えを更新しました。しかし、それには大きな意味はありません。おそらく、行が膨大な回数実行された場合、その行が不必要に使用されているかどうかチェックしたいかもしれませんが、大したことではないでしょうか。 – echonax