yonaskolb / XcodeGen

A Swift command line tool for generating your Xcode project
MIT License
7.01k stars 819 forks source link

Frameworks unit tests in app #461

Open raptorxcz opened 5 years ago

raptorxcz commented 5 years ago

Hi,

I have Application with frameworks. Each framework has its own scheme and own unit tests. Application do not have its own unit tests, instead it runs all frameworks unit tests.

How do I achieve this behaviour in XcodeGen?

I tried set it in scheme, but it is not working.

scheme:
      testTargets:
        - frameworkATests
        - frameworkBTests
        - frameworkCTests
        ...

For this settings I get error: - Target "Application" scheme has invalid test "frameworkATests"

I would expect something like implicit keyword or path to the original project.

49642090-59568d80-fa12-11e8-97bb-76e5f6c19c0c 49642091-59568d80-fa12-11e8-9627-09ecebf84f0c 49642092-59568d80-fa12-11e8-970d-bb6d7b44cee3

raptorxcz commented 5 years ago

Resolved in PR https://github.com/yonaskolb/XcodeGen/pull/466

yonaskolb commented 5 years ago

So I guess the issue was that the targets were in another project? Do you have multiple specs?

raptorxcz commented 5 years ago

Oh, I forgot to mention, each framework have its own project. So the application project contains only application files. I wanted to run frameworks tests from different project.

yonaskolb commented 5 years ago

Yes I see. Thanks for your PR. I’ll have a look over it in the next couple of days. I’ve just been taking some time off in the holidays

yonaskolb commented 5 years ago

Hi @raptorxcz, are your projects in the same workspace? The plan is to add workspace support with multiple projects, with cross project dependencies (including tests)

raptorxcz commented 5 years ago

Hi @yonaskolb, yes they are in same workspace. If you resolve this issue with another solution, I can close my MR. When I look at attached images, I think workspace is not required for this functionality.

Utsira commented 4 years ago

I've been able to add multiple test targets to the main app scheme using the new projectReference feature added in v 2.10. I think the ProjectSpec.md documentation doesn't make this clear. It says you can use a project reference for the coverageTargets field, but doesn't mention that you can also use project references in the targets field, but this works:

projectReferences:
  MyGreatFramework:
    path: Modules/Features/MyGreatFramework/MyGreatFramework.xcodeproj

schemes:
  AwesomeApp-PROD:
    build:
      targets:
        AwesomeApp: all
    test:
      targets:
        - AwesomeAppTests
        - MyGreatFramework/MyGreatFrameworkTests
      gatherCoverageData: true