kiwi-bdd / Kiwi

Simple BDD for iOS
BSD 3-Clause "New" or "Revised" License
4.14k stars 512 forks source link

Fix Travis CI builds #703

Closed ecaselles closed 6 years ago

ecaselles commented 6 years ago

This PR fixes the bug that was preventing all new CI builds to fail.

Problem:

Builds in Travis CI fail although all tests are passing:

Executed 376 tests, with 0 failures (0 unexpected) in 2.300 (3.782) seconds

ruby test_suite_configuration.rb xcodebuild.log
error: expected xcodebuild.log to include beforeAllSpecs and afterAllSpecs in its output
make: *** [test-iphone32] Error 1

The command "make ci" exited with 2.

This is due to the check done in test_suite_configuration.rb, which expects Xcode's logs to contain mentions to beforeAllSpec and afterAllSpec. Its purpose is to ensure these two lines run and therefore are properly tested. Unfortunately, this code is no longer run.

Solution:

After investigating the issue, apparently this is due to the swizzling done in KWAllTestsSuite.m not being run, which means that the XCTestSuite is never replaced with Kiwi's custom _KWAllTestsSuite. Therefore the beforeAll and afterAll do not run.

The cause behind it is that the method kiwi_testSuiteWithName is no longer called with "All tests" as an argument, which prevents the swizzling from happening (see this if statement). Instead, now it receives the tests target name as the suite name (e.g. "YourTestsTarget.xctest"). This must be a change introduced in XCTest that we were not aware of.

Therefore, the proposed solution is to allow the swizzling to run also if the suite name contains the ".xctest" prefix, meaning it is an XCTestSuite.

For compatibility, I am leaving the "All tests" check. But my feeling is that we could probably remove it.

orta commented 6 years ago

Agree, lets get this in - good job @ecaselles