【发布时间】:2019-01-25 23:38:08
【问题描述】:
我已经使用 Angular 6 创建了一个基本的模板应用程序,我正在尝试让 Stryker 突变测试对其进行工作。在基本主页上:
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 似乎没有一种方法可以忽略一段代码作为替代方法。
【问题讨论】:
标签: angular mutation-testing stryker