CucumberSwift
CucumberSwift copied to clipboard
Scenarios are running 2 times
Is there any reason, why should my scenarios run two times? I cannot find any settings for this. They even run two times when they are successful.
Originally posted by @SurglogsGithubUser in https://github.com/Tyler-Keith-Thompson/CucumberSwift/discussions/85
Relevant info: CocoaPods is the package manager. May be able to use the Cucumber Swift Sample repo to repro
Not able to repro: https://github.com/Tyler-Keith-Thompson/CucumberSwift/discussions/85#discussioncomment-5763839
Suspect that perhaps the new way we show tests from #72 is just confusing folks who use the test navigator rather than the report navigator.
Hi, sadly no, they actually run two times. I will try to debug the code and find the reason why that is.
Even override public class var defaultTestSuite: XCTestSuite
in open class CucumberTest: XCTestCase
is called two times. Do You have any idea, why that might be? Thank You
Hi, I just want to remind myself with this issue. Do You have any idea why this might be?
Apologies, I haven't been able to repro and I haven't had much time to dedicate to this project. I expect things will ease up in a few weeks.
Hi, I managed to check, if test is running for second time and stop it then.
open class CucumberTest: XCTestCase {
static var didRun = false
open override func invokeTest() {
guard !Self.didRun else {return}
Self.didRun = true
super.invokeTest()
}
...
I'm glad you have a workaround! It's very weird that that's necessary. This is actually quite insightful, because it means that XCTest is picking up on the entire test case twice, (as opposed to tests accidentally running themselves repeatedly, or something).
Hi @Tyler-Keith-Thompson ,
Outstanding work on this project.
I ran into this issue as well and the following change seems to resolve it. I only see one invocation of my tests now, not two:
open class CucumberTest: XCTestCase {
static var didRun = false
static var didInitTestSuite = false
override open func invokeTest() {
guard !Self.didRun else { return }
Self.didRun = true
super.invokeTest()
}
override public class var defaultTestSuite: XCTestSuite {
guard !Self.didInitTestSuite else { return XCTestSuite(name: "empty") }
Self.didInitTestSuite = true
I'm happy to send a pull request and will do it soon.
@Tyler-Keith-Thompson can you please review my PR #101 ?
@Tyler-Keith-Thompson can we close this issue now?
Yes, thank You