Skip to content

Group steps per scenario in test report #72

@Hsilgos

Description

@Hsilgos

Hi again. May I ask if there is a reason why all steps are listed as plain list in test results?
I tried the following:

public final class CucumberTest: XCTestCase {
    override public class var defaultTestSuite: XCTestSuite {
        ....
        // Instead of this:
        // allGeneratedTests.forEach { suite.addTest($0) }
        // Call this:
        generateAlltests(suite)
        return suite
    }

    static func generateAlltests(_ rootSuite: XCTestSuite) {
        for feature in Cucumber.shared.features.taggedElements(with: Cucumber.shared.environment, askImplementor: false) {
            let className = feature.title.toClassString() + readFeatureScenarioDelimiter()

            for scenario in feature.scenarios.taggedElements(with: Cucumber.shared.environment, askImplementor: true) {
                let childSuite = XCTestSuite(name: scenario.title.toClassString())
                var tests = [XCTestCase]()
                createTestCaseFor(className: className, scenario: scenario, tests: &tests)
                tests.forEach{ childSuite.addTest($0) }
                rootSuite.addTest(childSuite)
            }
        }
    }

And my test reports become much nicer, see screenshot.
Does it make sense to continue to improve in this direction?

Screenshot 2023-02-02 at 23 07 56

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions