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

Set TEST_HOST and BUNDLE_LOADER for app unit tests #300

Merged
merged 8 commits into from Mar 23, 2019
Merged

Conversation

ollieatkinson
Copy link
Collaborator

set TEST_HOST and BUNDLE_LOADER for Unit tests bundle for an app target so that the default generated test target runs

Resolves #204

Short description πŸ“

The default generated project did not set these two build configurations which meant that the app unit test target was not able to resolve the symbols stores inside of the application.

Solution πŸ“¦

By setting TEST_HOST and BUNDLE_LOADER ld is able to link the symbols and run the unit tests.

The implementation will look at the dependencies for the test target and the find the app to set as the test host. Currently this selects the first app, but we can expand on this in the future as and when we better understand peoples requirements.

Test Plan πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

  • Enable all unit tests for applications inside of fixtures
  • bundle exec rake features
  • swift test

@ollieatkinson ollieatkinson requested a review from a team March 22, 2019 19:34
@codecov
Copy link

codecov bot commented Mar 22, 2019

Codecov Report

Merging #300 into master will decrease coverage by 0.02%.
The diff coverage is 96.8%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #300      +/-   ##
==========================================
- Coverage   89.25%   89.22%   -0.03%     
==========================================
  Files         279      276       -3     
  Lines       10619    10501     -118     
==========================================
- Hits         9478     9370     -108     
+ Misses       1141     1131      -10
Impacted Files Coverage Ξ”
...uistKitTests/Generator/SchemesGeneratorTests.swift 100% <ΓΈ> (ΓΈ) ⬆️
...Generator/TestData/GeneratedProject+TestData.swift 0% <0%> (ΓΈ) ⬆️
...TuistKitTests/Generator/ConfigGeneratorTests.swift 98.93% <100%> (+0.47%) ⬆️
Sources/TuistKit/Generator/ConfigGenerator.swift 98.14% <100%> (+0.14%) ⬆️
Sources/TuistKit/Generator/GeneratedProject.swift 100% <100%> (ΓΈ) ⬆️
Sources/TuistKit/Generator/TargetGenerator.swift 100% <100%> (ΓΈ) ⬆️
Sources/TuistKit/Generator/ProjectGenerator.swift 98.91% <92.85%> (-1.09%) ⬇️
...uistKitTests/Generator/ProjectGeneratorTests.swift 98.61% <97.43%> (-1.39%) ⬇️
Sources/TuistKit/Utils/InfoPlistProvisioner.swift 100% <0%> (ΓΈ) ⬆️
Sources/TuistKit/Models/Platform.swift 100% <0%> (ΓΈ) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update c910164...dc6d989. Read the comment docs.

@tuistbot
Copy link
Contributor

tuistbot commented Mar 22, 2019

1 Warning
⚠️ Have you introduced any user-facing changes? If so, please take some time to update the documentation. Keeping the documentation up to date makes it easier for users to learn how to use Tuist.

Generated by 🚫 Danger

@kwridan
Copy link
Collaborator

kwridan commented Mar 23, 2019

Nice to see this being finally resolved! πŸ‘

Sadly UI tests targets won't work with this :/

Screen Shot 2019-03-23 at 9 29 39 AM

Target(name: "AppUITests",
                                 platform: .iOS,
                                 product: .uiTests,
                                 bundleId: "io.tuist.AppUITests",
                                 infoPlist: "Tests.plist",
                                 sources: "UITests/**",
                                 dependencies: [
                                     .target(name: "App"),
                                 ])

@ollieatkinson
Copy link
Collaborator Author

ollieatkinson commented Mar 23, 2019

Thanks @kwridan - I've fixed the issue here: 43e1ab5

I set TEST_TARGET_NAME and ensured that the test target identity was being set at the top level PBXProject. I also added the ui tests to the ios_app_with_tests fixture.

I've rebased the work against master to test against the latest changes.

Copy link
Collaborator

@kwridan kwridan left a comment

Choose a reason for hiding this comment

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

nice work πŸ‘ - both unit and ui tests now work!

We can revisit this and consider the enum solution suggested on the original issue (option 3 in #204) once we find more use cases for product specific attributes.

Sources/TuistKit/Generator/ProjectGenerator.swift Outdated Show resolved Hide resolved
features/generate.feature Show resolved Hide resolved
Sources/TuistKit/Generator/ConfigGenerator.swift Outdated Show resolved Hide resolved
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.

Unit tests bundle for an app target does not compile
4 participants