Files
Kiwi/test_suite_configuration.rb
Adam Sharp 1a6a5e6413 Implement before/after all specs hooks by swizzling +[XCTestSuite testSuiteWithName:]
The XCTestObserver implementation of beforeAllSpecs/afterAllSpecs wasn't
stable. At various times the hooks would run from within the Kiwi
project, or from an external test suite, but usually not from both, and
it was never clear what caused it to work or not. Setting values in
NSUserDefaults at load time doesn't seem to be a stable strategy.

This implementation swizzles +[XCTestSuite testSuiteWithName:] and looks
for a suite named "All tests". It then dynamically sets the class of the
"All tests" suite to be a custom subclass that overrides setUp and
tearDown to call KWSuiteConfigurationBase.

Also adds an integration test step in the Makefile that looks through
the xcodebuild.log output for the strings "beforeAllSpecs" and
"afterAllSpecs" as an indication that the config hooks were executed
(logged from Tests/Config.m).

Finally, the beforeEachSpec and afterEachSpec have been removed from the
public interface of KWSuiteConfigurationBase as they are still
unimplemented.
2014-07-07 19:41:06 +10:00

16 lines
291 B
Ruby

#!/usr/bin/ruby
file = ARGV.shift
expected = <<-EOF
beforeAllSpecs
afterAllSpecs
EOF
pattern = "(before|after)AllSpecs$"
unless %x(grep -E -o '#{pattern}' #{file}) == expected
STDERR.puts "error: expected #{file} to include beforeAllSpecs and afterAllSpecs in its output"
exit 1
end