2017-11-22 1 views
0

「テストコンポーネント」のテストケースがいくつか書かれています。しかし、テストケースをUnitまたはe2eとAngularで分類するにはどうすればよいですか?Inユニットテストケースとe2eテストケースのどちらを決定するかテストするには?

+0

を持っています。 '単体テスト'の定義に合っていれば単体テストです。それが 'e2e'の定義に合っていれば、それはe2eです。あなたの現在のテストを投稿することをお勧めします。まだ広すぎるかもしれず、https://codereview.stackexchange.com/に属していますが、少なくとも回答は可能です。 – estus

答えて

1

ユニットテストとe2eテストの違いは何ですか?

E2Eはあなたのビューをテストし、あなたのフレームワーク/ライブラリの依存とユニットテストは、ビジネス・ロジックをテストします。

私は、このようなもの、それは確かにE2Eテストだあなたの角度成分の参照を持っている場合:あなたは、角CLI、.spec.tsファイルを使用してコンポーネントを生成する場合

import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 
import { LoaderComponent } from './loader.component'; 

describe('LoaderComponent',() => { 
    let component: LoaderComponent; 
    let fixture: ComponentFixture<LoaderComponent>; //<- ref of the angular component 

    beforeEach(async(() => { 
    TestBed.configureTestingModule({ 
     declarations: [ LoaderComponent ] 
    }) 
    .compileComponents(); 
    })); 

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

    it('should be created',() => { 
    expect(component).toBeTruthy(); 
    }); 
}); 

を生成常にあります.css、.html、.tsを使用します。


第三者フレームワークの角度についての説明がない場合は、あなたのテストは単位テストになります。このような何か:

describe("Determine min or max ticket per person",() => { 

    it('Should return the max if the min is greater',() => { 
    const min = 10 
    const max = 5 
    expect(TicketDataSpecification.determineMinPerPerson(min, max)).toEqual(max) 
    }) 

    it('Should return the min if the max is less',() => { 
    const min = 10 
    const max = 5 
    expect(TicketDataSpecification.determineMaxPerPerson(min, max)).toEqual(min) 
    }) 

    it('Should return the quantity if the min is greater',() => { 
    const min = 10 
    const quantity = 5 
    expect(TicketDataSpecification.determineMinPerPersonWithQuantity(min, quantity)).toEqual(quantity) 
    }) 

    it('Should return the quantity if the max is greater',() => { 
    const max = 10 
    const quantity = 5 
    expect(TicketDataSpecification.determineMaxPerPersonWithQuantity(max, quantity)).toEqual(quantity) 
    }) 

}) 

その後、あなたは、などの仕様のテスト、統合テスト、...広すぎる

+0

https://stackoverflow.com/users/7152354/[email protected] thanks –

関連する問題