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

Pending Example Impovement #491

Closed
wants to merge 27 commits into from
Closed

Pending Example Impovement #491

wants to merge 27 commits into from

Conversation

takecian
Copy link
Contributor

This PR is related to #490 .

  • print detailed description for pending example
  • execute before/after hooks for pending example
  • rename Filter.pending to Filter.excluded

please review, thanks.
Takeshi.

@takecian
Copy link
Contributor Author

@modocache, if you have spare time, it would be helpful that you review this! 👍

}

func testBeforeEachDoesNotRunForContextsWithOnlyPendingExamples() {
onlyPendingExamplesBeforeEachExecutedCount = 0

qck_runSpec(FunctionalTests_PendingSpec.self)
XCTAssertEqual(onlyPendingExamplesBeforeEachExecutedCount, 0)
XCTAssertEqual(onlyPendingExamplesBeforeEachExecutedCount, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion no longer matches the name of the test. The test is named "test that beforeEach does not run for contexts with only pending examples", whereas this assertion verifies that beforeEach does run. The same goes for testBeforeEachOnlyRunForEnabledExamples above.

So, why do these tests exist? pending examples were first implemented in #38. At that time, Quick had an ad hoc test suite: a single test file that used Quick and was expected to pass. I added in-depth tests in #154, which included tests for pending in 6b7681b. Unfortunately, I neglected to realize the importance of documenting in the commit message whether beforeEach not running was intended, or merely the behavior at the time that I wrote these tests.

I think these tests merely documented the behavior of pending at the time. It seems like the purpose of this PR is to ensure that beforeEach, afterEach, beforeSuite, and afterSuite always run, even for pending examples. If that's the case, please:

  1. Delete the testBeforeEachOnlyRunForEnabledExamples and testBeforeEachDoesNotRunForContextsWithOnlyPendingExamples tests.
  2. Add tests for beforeEach, afterEach, beforeSuite, and afterSuite.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated test(add tests for beforeEach, afterEach, beforeSuite, and afterSuite) and create new target.
See also, #491 (comment) 😄

@modocache
Copy link
Member

@takecian This is awesome!! Thanks for working on this, and sorry for the wait in reviewing.

}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-pick: Remove this extra whitespace.

@modocache
Copy link
Member

This looks great! I think the tests need some additional work, though. Thanks, @takecian!

@takecian
Copy link
Contributor Author

Thank you for review! I'll fix it!

@takecian
Copy link
Contributor Author

Hi @modocache , I've updated comment and added test for pending.
It would be helpful to review this.

Thanks!

beforeEach { isBeforeEachCalled = true }
pending("an example that will not run") {}
afterEach { isAfterEachCalled = true }
afterSuite { isAfterSuiteCalled = true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this is almost what we want. However, the beforeSuite and afterSuite tests here will pass even without your changes. This is because this test suite contains non-pending examples. To really test these, you'd need an entirely new test target in the Quick workspace -- just like the QuickFunctionalTests target.

I think we should test this in a new QuickPendingTests target.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I understand. I will create new test target and move this test into it.

@takecian
Copy link
Contributor Author

I've created new test target for "pending" and merged master branch.
How do you feel?

@modocache
Copy link
Member

Looking good! There are build failures on Linux, though. I think you'll need to use #file and #line instead of __FILE__ and __LINE__.


Mock makes us easy to verify behavior which works with other objects.

For more details about writing test, see https://realm.io/news/testing-in-swift/ .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am planning on reviewing this additional documentation in #487, but I don't think you meant to include it in this pull request. Could you take it out?

@takecian
Copy link
Contributor Author

takecian commented May 24, 2016

I did,

However build error on linux still occcurs. I will work for it.

@takecian
Copy link
Contributor Author

@modocache , I've fixed errors on linux.
Could you review again?

@karagraysen karagraysen self-assigned this Aug 10, 2016
@karagraysen karagraysen changed the title pending example impovement Pending Example Impovement Aug 11, 2016
@karagraysen
Copy link

@modocache: Do you have time to review this?

@karagraysen
Copy link

@modocache: Re-pinging, just in case the notification or email got lost. 👍

@modocache
Copy link
Member

Didn't get lost, but it's a lot to review! 😅

I'll need to find some time to read through it. Hopefully sometime this week.

@karagraysen
Copy link

Okay, no problem. Didn't know if you had seen it or not. 😸 I'll assign the PR to you?

@karagraysen karagraysen assigned modocache and unassigned karagraysen Aug 23, 2016
@karagraysen karagraysen self-assigned this Nov 8, 2016
@karagraysen
Copy link

Bringing attention back to this. Could we get the merge conflicts fixed @takecian and have it reviewed @modocache. Cheers! :)

@karagraysen
Copy link

@takecian: Please fix the merge conflicts so we can finish reviewing your changes.

@ikesyo
Copy link
Member

ikesyo commented Oct 8, 2020

Closing as this is stale/abandoned.

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

Successfully merging this pull request may close these issues.

Using pending causes custom Configuration hooks not to run
4 participants