Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Week 2] isInverted #5

Open
hope1053 opened this issue Sep 26, 2022 · 0 comments
Open

[Week 2] isInverted #5

hope1053 opened this issue Sep 26, 2022 · 0 comments

Comments

@hope1053
Copy link
Member

궁금한점

isInverted를 왜 사용해야하는지?

  • isInverted가 적용된 코드
func testPostDouble_generatesOnlyOneNotification() {
    // given
    let exp = expectation(forNotification: AlertNotification.name, object: sut)
    exp.expectedFulfillmentCount = 2
    exp.isInverted = true
    
    let alert = Alert("this is an alert")
    
    // when
    sut.postAlert(alert: alert)
    sut.postAlert(alert: alert)
    
    // then
    wait(for: [exp], timeout: 1)
  }
  • 위 코드를 왜 아래처럼 작성하지 않았는지 궁금 ! 도대체 isInverted를 어떻게 써야 잘 썼다고 들을 수 있을까?
func testPostDouble_generatesOnlyOneNotification() {
    //given
    let exp = expectation(
      forNotification: AlertNotification.name,
      object: sut,
      handler: nil)
    exp.expectedFulfillmentCount = 1
    let alert = Alert("this is an alert")

    // when
    sut.postAlert(alert: alert)
    sut.postAlert(alert: alert)

    // then
    wait(for: [exp], timeout: 1)
  }

찾아본 것

this test fails if the expectation is fulfilled and succeeds if the wait times out
= this test will fail if two notifications are triggered by the two alerts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant