AliSoftware / OHHTTPStubs

Stub your network requests easily! Test your apps with fake network data and custom response time, response code and headers!
MIT License
5.03k stars 601 forks source link

Conditional Compilation Fixes. #302

Closed jeffctown closed 5 years ago

jeffctown commented 5 years ago

Uncommenting buggy redirect tests. Adding xcconfig to put project settings into. Adding preprocessor macros to let unit test arguments through. Adding default value of preprocessor macros to default them to run conditional tests when using Xcode. Adding comments for xcconfig. Updating Rake arguments.

Checklist

Description

My original goal was to add a previously commented unit test back to the test suite, and to enable it when testing in Xcode but disable it when testing in CI. During this investigation, I also noticed that the Timing Tests were not working in this way like they were originally intended to. I ended up fixing those tests in this PR too.

Motivation and Context

Timing Tests -

If you look at previous test runs, you see that timing tests were being run in Travis:

screen shot 2019-03-07 at 7 03 59 am

Even though the right Xcode argument was being passed:

screen shot 2019-03-07 at 7 04 15 am

This seems like a bug with the project setup.

I found that we needed to add a preprocessor macro to the project's build settings to let the xcodebuild argument through.

I always like using xcconfig files to manage build settings, so I created a project level xcconfig with the build settings and commented the config. Build settings that are defined in xcconfig files can always be overridden by passing in xcodebuild arguments.

Redirect Tests -

I followed the same pattern with the uncommented redirect tests.

End Result -

You can see here that both sets of tests are run when using Xcode:

screen shot 2019-03-07 at 9 11 00 am

And that neither are ran during CI:

screen shot 2019-03-07 at 9 22 17 am
AliSoftware commented 5 years ago

Man it's so refreshing to see CI turn green on the PR without having to restart every CI job manually and pray until it passes 😄🎉