You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## ⚪ ️1.9 Avoid global test fixtures and seeds, add data per-test
518
-
519
-
:white_check_mark:**Do:** Going by the golden rule (bullet 0), each test should add and act on its own set of DB rows to prevent coupling and easily reason about the test flow. In reality, this is often violated by testers who seed the DB with data before running the tests ([also known as ‘test fixture’](https://en.wikipedia.org/wiki/Test_fixture)) for the sake of performance improvement. While performance is indeed a valid concern — it can be mitigated (see “Component testing” bullet), however, test complexity is a much painful sorrow that should govern other considerations most of the time. Practically, make each test case explicitly add the DB records it needs and act only on those records. If performance becomes a critical concern — a balanced compromise might come in the form of seeding the only suite of tests that are not mutating data (e.g. queries)
520
-
<br/>
517
+
## ⚪ ️ 1.9 테스트 데이터를 글로벌로 하지말고 테스트별로 따로 추가하라.
521
518
519
+
:white_check_mark:**이렇게 해라:** 황금률에 따르면(섹션 0), 각 테스트는 커플링을 방지하고 테스트 흐름을 쉽게 추론하기 위해 자체 DB 데이터를 추가하고 실행해야 합니다. 실제로 성능 향상(테스트를 실행하기 전에 DB 데이터를 준비(['테스트 픽스쳐'라고도 합니다](https://en.wikipedia.org/wiki/Test_fixture)))을 위해 이를 위반하는 테스터들이 많습니다. 성능은 실제로 유효한 문제이지만 완화될 수 있습니다(2.2 컴포넌트 테스트 참고). 그러나 테스트 복잡성은 대부분의 다른 고려사항들을 통제해야 하는 고통을 수반합니다. 각 테스트에 필요한 DB 레코드를 명시적으로 추가하고, 해당 데이터에 대해서만 테스트를 수행하십시오. 성능이 중요한 문제가 되는 경우 - 데이터를 변경하지 않는 테스트 모음(예: 쿼리)에 대해서 데이터를 준비하는 형태로 타협할 수 있습니다.
522
520
523
-
❌ **Otherwise:** Few tests fail, a deployment is aborted, our team is going to spend precious time now, do we have a bug? let’s investigate, oh no — it seems that two tests were mutating the same seed data
521
+
<br/>
524
522
523
+
❌ **그렇지 않으면:** 테스트 실패, 배포 중단으로 팀원들이 귀중한 시간을 소비할 것입니다. 버그가 있습니까? 조사해보니 '없습니다' - 두 테스트에서 동일한 테스트 데이터를 변겨안 것으로 보입니다.
expect(siteToCheck.name).to.be.equal("Portal"); //Failure! The previous test change the name :[
550
+
expect(siteToCheck.name).to.be.equal("Portal"); // 실패! 이전 테스트에서 이름이 변경되었습니다. ㅠㅠ
552
551
});
553
-
554
552
```
553
+
555
554
<br/>
556
555
557
-
### :clap:Doing It Right Example: We can stay within the test, each test acts on its own set of data
556
+
### :clap:올바른 예: 우리는 테스트 내부에만 머물 수 있으며, 각 테스트는 자체 데이터 세트에서 동작합니다.
558
557
559
558
```javascript
560
-
it("When updating site name, get successful confirmation", async () => {
561
-
//test is adding a fresh new records and acting on the records only
559
+
it("사이트 이름을 업데이트 할 때, 성공을 확인한다.", async () => {
560
+
// 테스트는 새로운 레코드를 새로 추가하고 해당 레코드에 대해서만 동작합니다.
562
561
constsiteUnderTest=awaitSiteService.addSite({
563
562
name:"siteForUpdateTest"
564
563
});
@@ -567,13 +566,11 @@ it("When updating site name, get successful confirmation", async () => {
567
566
568
567
expect(updateNameResult).to.be(true);
569
568
});
570
-
571
569
```
572
570
573
571
</details>
574
572
575
-
576
-
<br/>
573
+
<br/><br/>
577
574
578
575
## ⚪ ️ 1.10 Don’t catch errors, expect them
579
576
:white_check_mark:**Do:** When trying to assert that some input triggers an error, it might look right to use try-catch-finally and asserts that the catch clause was entered. The result is an awkward and verbose test case (example below) that hides the simple test intent and the result expectations
0 commit comments