1

Angular 6 で基本的なテンプレート アプリケーションを作成し、 Stryker Mutation テストを実行しようとしています。基本的なホームページ:

import { Component } from '@angular/core';

/**
* Home Page Definition
*/
@Component({
    selector: 'app-home',
    templateUrl: 'home.page.html',
    styleUrls: ['home.page.scss']
})
export class HomePage {}

このページの基本的なテスト ファイルがあります。

import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { HomePage } from './home.page';

/**
* Home Page Test File
*/
describe('HomePage', () => {
    let component: HomePage;
    let fixture: ComponentFixture<HomePage>;

    beforeEach(async(() => {
        TestBed.configureTestingModule({
            declarations: [HomePage],
            schemas: [CUSTOM_ELEMENTS_SCHEMA]
        }).compileComponents();
    }));

    beforeEach(() => {
        fixture = TestBed.createComponent(HomePage);
        component = fixture.componentInstance;
        fixture.detectChanges();
    });

    it('should create', () => {
        expect(component).toBeDefined();
        expect(component).toBeTruthy();
    });

    it('should be proper component', () => {
        expect(component).toBeInstanceOf(HomePage);
    });
});

これは成功し、ホームページが作成されることをテストしますが、 ストライカー変異エラー.

基本的なホームページでは、@Component に 3 つのフィールドがあり、それらはすべてリテラル テキストであるため、ミュータント サバイバーを生成します。これらのミュータント生存者を殺すテストの書き方がわかりません。

条件を処理するためのテストを記述できない場合、代替手段としてコードのセクションを無視する方法が Stryker にあるようには見えません。

4

1 に答える 1