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

Add Test Plans #716

Merged
merged 21 commits into from
May 10, 2022
Merged

Add Test Plans #716

merged 21 commits into from
May 10, 2022

Conversation

yonaskolb
Copy link
Owner

@yonaskolb yonaskolb commented Nov 10, 2019

Adds test plan support
Resolves #684

  • reference test plans in schemes
  • generate test plan references in schemes
  • parsing tests
  • generation tests
  • updates scheme versions
  • remove xctestplan from resources
  • validation errors
  • validation tests
  • ability to define test plans in spec (probably not required) OR:
  • way to update UUID references in test plan files
  • docs

Possible changes:

  • make top level testPlans which are then referenced in schemes, similar to the new projectReferences?
  • ability to choose a default test plan? At the moment the first test plan in a scheme will be the default
  • ability to define test plans in the spec itself? If not we probably need a way to update the UUIDs in existing files in case XcodeGen/XcodeProj ever changes them


static var pathProperties: [PathProperty] {
[
.string("testPlans")
Copy link
Owner Author

Choose a reason for hiding this comment

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

This file is getting large, gonna split it up

Copy link
Collaborator

@giginet giginet left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -194,10 +194,18 @@ public class SchemeGenerator {
let launchVariables = scheme.run.flatMap { $0.environmentVariables.isEmpty ? nil : $0.environmentVariables }
let profileVariables = scheme.profile.flatMap { $0.environmentVariables.isEmpty ? nil : $0.environmentVariables }

var testPlans: [XCScheme.TestPlanReference]?
Copy link
Collaborator

@giginet giginet Nov 10, 2019

Choose a reason for hiding this comment

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

You can use let

let testPlanns: [XCScheme.TestPlanReference]? = scheme.test?.testPlans.map { plans in
    return plans.enumerated().map { index, path in
        .init(reference: "container:\(path)", default: index == 0)
    }
}

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah there’s a few ways to do it. The property has to be nil if there are no test plans though, as that’s what XcodeProj expects

Copy link
Collaborator

Choose a reason for hiding this comment

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

Points of my comment was avoiding using mutable variables as we can.
Type should be [XCScheme.TestPlanReference]? Sorry.

@min
Copy link
Contributor

min commented Jan 22, 2020

@yonaskolb any updates on release for this? would love to start migrating to test plans.

@armintelker
Copy link

I really like to use XcodeGen but our project is build up on test plans. Is here any update.

@soffes
Copy link
Contributor

soffes commented Mar 21, 2020

Really looking forward to this! Thanks for your effort on this feature! <3

@pinda
Copy link
Contributor

pinda commented Apr 21, 2020

Looking forward to this! Any ETA on when this will become available?

@omares
Copy link
Contributor

omares commented Apr 24, 2020

hey @yonaskolb / @giginet is there anything one can do to help out finializing this? I would like to give it a try and pick this up.

@omares
Copy link
Contributor

omares commented Apr 24, 2020

Went ahead and created an up-to-date version of the branch, tried my best to resolve the conflicts, but i really need some hints what the actual code was lacking. :D

Edit 1: Started with the simplest one: Adding documentation

Edit 2: Guess I understand the to-dos now. First up ill add the option to define a default test plan, after that ill try to add spec validation.

@omares omares mentioned this pull request Apr 24, 2020
11 tasks
@omares
Copy link
Contributor

omares commented Apr 24, 2020

I created a draft PR #846 that contains the default test plan option, validation errors + tests and the updated documentation. It only lacks the uuid update, would love to hear hints on how to tackle that. I would suggest taking further discussions, on how to proceed to the new PR.

@brentleyjones brentleyjones removed their request for review January 6, 2021 14:28
@popwarfour
Copy link

Would love this feature!

@Almaz5200
Copy link

Hi! Any updates on when this PR is going to be merged?

@SentoCrespo
Copy link

+1 to test plans!

@DmitryShapovalov
Copy link

DmitryShapovalov commented Mar 29, 2022

also, +1 for test plans!

@SentoCrespo
Copy link

Just in case you missed this, I won't spam anymore, promised :D

@giginet
@kateinoigakukun
@ryohey

@SarannyaSalim
Copy link

+1 to test plans

1 similar comment
@rublagar
Copy link

+1 to test plans

@hakkurishian
Copy link
Contributor

+++++++1 :)

yonaskolb and others added 11 commits May 9, 2022 20:37
# Conflicts:
#	Sources/ProjectSpec/Scheme.swift
#	Sources/XcodeGenKit/SourceGenerator.swift
#	Tests/Fixtures/SPM/SPM.xcodeproj/project.pbxproj
#	Tests/Fixtures/SPM/SPM.xcodeproj/xcshareddata/xcschemes/App.xcscheme
#	Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj
#	Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/App_Scheme.xcscheme
#	Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/App_iOS Production.xcscheme
#	Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/App_iOS Staging.xcscheme
#	Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/App_iOS Test.xcscheme
#	Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/App_macOS.xcscheme
#	Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/App_watchOS.xcscheme
#	Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/Framework.xcscheme
#	Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/Tool.xcscheme
#	Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/iMessageApp.xcscheme
#	Tests/Fixtures/TestProject/project.yml
#	Tests/ProjectSpecTests/SpecLoadingTests.swift
#	Tests/XcodeGenKitTests/SchemeGeneratorTests.swift
# Conflicts:
#	Sources/ProjectSpec/Scheme.swift
#	Tests/Fixtures/paths_test/included_paths_test.yml
#	Tests/ProjectSpecTests/SpecLoadingTests.swift
# Conflicts:
#	Tests/ProjectSpecTests/ProjectSpecTests.swift
# Conflicts:
#	Sources/ProjectSpec/FileType.swift
@yonaskolb
Copy link
Owner Author

Ok, have found some time to pick this up! I've pulled in changes from #846 and also made some further additions.
This is now at a point where it's usable with some big caveats for now. As the docs now say:

For now test plans are not generated by XcodeGen and must be created in Xcode and checked in, and then referenced by path. If the test targets are added, removed or renamed, the test plans may need to be updated in Xcode.

I hope this is useable in its current state for some people. The plan is to release this in the next version.

In terms of fully specced and generated test plans that is a whole bunch more work:

  • Support for these types of files in XcodeProj Add support for test plans tuist/XcodeProj#484
  • The addition of Test Plans in the project spec. The test plan file format is also expected to be a configuration file that changes often with Xcode releases making the spec hard to keep up to date.

@yonaskolb yonaskolb merged commit e35f7df into master May 10, 2022
@yonaskolb yonaskolb deleted the test_plans branch May 10, 2022 03:27
@yonaskolb
Copy link
Owner Author

Released in 2.29.0

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

Successfully merging this pull request may close these issues.

Support for TestPlan