mirror of
https://github.com/zhigang1992/Kiwi.git
synced 2026-01-12 17:23:17 +08:00
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.
16 lines
291 B
Ruby
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
|