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

Improper use of expect() in describe() block cause test-case enumeration to fail #1074

Open
1 task done
KentLottis-jwn opened this issue Aug 5, 2023 · 2 comments
Open
1 task done

Comments

@KentLottis-jwn
Copy link

  • I have read CONTRIBUTING and have done my best to follow them.

What did you do?

We found a malformed spec that had gone undiscovered under older versions of Quick/Nimble. Specifically, the spec author had failed to nest an expect() clause inside an it() block. Previously, this was silently ignored. Now it results in no tests being executed.

What did you expect to happen?

Ideally, we would get some sort of run-time diagnostic pointing to the coding error. At the very least, the other well-formed test cases in the spec should execute normally.

What actually happened instead?

The spec fails to run any tests.

Environment

List the software versions you're using:

  • Quick: 7.2.0
  • Nimble: 12.2.0
  • Xcode Version: 14.3.1
  • Swift Version: Xcode Default

Please also mention which package manager you used and its version. Delete the
other package managers in this list:

  • Swift Package Manager 5.8.1

Project that demonstrates the issue

Easier to just paste in the repro case

I would expect this spec to result in one test failure. Instead, not tests are executed.

class BrokenSpec: QuickSpec {
    override class func spec() {
        describe("a well-formed describe") {
            it("fails") {
                expect("a").to(equal("b"))
            }
        }

        describe("a malformed describe") {
           // this is, of course, a coding mistake - there should be an enclosing it() block
           // but it would be nice if the runtime would catch this
            expect("a").to(equal("b"))
        }
    }
}
@KentLottis-jwn
Copy link
Author

Note: one might think that this is actually an issue with Quick, since it concerns test-case enumeration (a Quick behavior) as opposed to assertion handling (the core Nimble behavior). However, if I replace the expect() clause with an equivalent XCTAssertEqual("b", "a"), then the test case is enumerated as desired.

@younata
Copy link
Member

younata commented Aug 21, 2023

Note: one might think that this is actually an issue with Quick, since it concerns test-case enumeration (a Quick behavior) as opposed to assertion handling (the core Nimble behavior). However, if I replace the expect() clause with an equivalent XCTAssertEqual("b", "a"), then the test case is enumerated as desired.

Fascinating. That doesn't seem like that should be the case.

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

No branches or pull requests

2 participants