CucumberSwift icon indicating copy to clipboard operation
CucumberSwift copied to clipboard

fix: resolve tests running twice

Open ianhlavats opened this issue 8 months ago • 0 comments

PR for #88.

This pull request primarily focuses on improving the execution of the test suite in the CucumberSwift project. The changes ensure that the default test suite is created only once and that tests are invoked only if they haven't run before. Additionally, a new test case has been added to verify this behavior.

Changes made:

  • Sources/CucumberSwift/Runner/CucumberTest.swift: Implemented a mechanism to ensure that the default test suite is created only once and that tests are invoked only if they haven't run before. This was achieved by introducing a static boolean didRun and a static XCTestSuite instance suiteInstance. didRun is checked before invoking a test and suiteInstance is checked before creating a new test suite. If suiteInstance already exists, it is returned instead of creating a new one.

  • Tests/CucumberSwiftTests/Reporter/CustomReporterTests.swift: Added a new test case testDefaultSuiteIsCreatedOnlyOnce to verify that the default test suite is indeed created only once. This test case runs a feature file, captures the default test suite before and after execution, and asserts that they are equal.

ianhlavats avatar Jul 01 '24 10:07 ianhlavats