-
Notifications
You must be signed in to change notification settings - Fork 511
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
Output formatters #449
Output formatters #449
Conversation
Conflicts: Classes/Matchers/KWBeZeroMatcher.m Kiwi.xcodeproj/project.pbxproj
@mneorr I think the changes to the output might have broken XCPretty's parser! 😆 The tests pass when run with |
This should probably be considered in conjunction with issue #222. |
There are 2 prints for each test when Kiwi runs:
I don't think you were able to affect the first one - have you tried piping it to xcpretty and testing results? |
The only difference is that Kiwi output no longer uses Current Kiwi output:
Output as of this pull request:
I can investigate why this is the case by looking at XCPretty, but that might be more trouble than it's worth, since I'm anticipating that the output will change based on your and other's feedback anyway. If it's not too much trouble I'd like to get some feedback on the feature as a whole. You can rest assured that before it's merged it'll be playing along with XCPretty. |
Oops, sorry, ignore that last post. Turns out it was an encoding issue. I switched the output to ASCII encoding and everything works for now. |
I'm pretty sure xcpretty doesn't read these |
Ah, that'll do it then--the formatters in this PR print to stderr unless told otherwise. Any thoughts on the PR? |
We should be able to do it with the shared // When Kiwi starts up, register the base defaults
[[NSUserDefaults standardUserDefaults] registerDefaults:@{
@"formatters": @"KWTextFormatter:stderr"
}];
// If -formatters is passed from the command line, that argument will take
// precedence. If no other default is found (for example, from the user's
// global defaults), the registered value will be used.
[[NSUserDefaults standardUserDefaults] stringForKey:@"formatters"]; Check out the documentation on A couple of ideas:
|
Conflicts: Classes/Core/Kiwi.h Kiwi.xcodeproj/project.pbxproj
@sharplet Thanks for the suggestion, but unfortunately I've tried using I've seen people say command-line arguments are accessible via these two, but it's not working for me, so I'm not sure if perhaps I'm doing something wrong... When running, I get the following output from
But the |
This was a neat idea, but I won't be working on it anytime soon for Kiwi. Still, building it was a ton of fun!! And I'm hoping to bake it into some sort of testing solution I make one day; perhaps Quick. Quick/Quick#9 |
Do not merge this yet. I'm issuing this pull request as an invitation for feedback.
One of the goals for issue #306 is to allow test custom test output. This pull request implements this feature in a similar way to how RSpec does it.
Feature Summary
Users may add a
KiwiConfiguration.plist
file to their test bundle. This plist may contain aformatters
key, which refers to a dictionary of key-value pairs in the formformatter_name: output_file_path
. For example:All formatter classes specified in the plist are registered to receive notifications regarding test execution via a new
KWReporter
singleton class. Users may specify any class, including ones they write themselves, so long as that class:KWListener
protocolFor example, specifying
KWJSONFormatter: /Users/modocache/Desktop/test-output.json
writes the following content to a file namedtest-output.json
on the Desktop:Implementation Summary
Here are the key players:
KWReporter
: A singleton which maintains an array of listeners.KWExample
informs the reporter whenever it passes, fails, etc. The reporter then informs each of its listeners of these events.KWListener
: A protocol defining how the reporter notifies listeners.KWFormatterLoader
: A class responsible for loading the formatters from the plist. If the plist does not exist,KWTextFormatter: stderr
is used.KWTextFormatter
: A formatter class which outputs the exact same text as theNSLog
statements in Kiwi 2.0 (minus the timestamps).KWJSONFormatter
: A formatter class which outputs JSON.The rest is in the diff. Sorry it's so huge. 😦
Specific Requests for Feedback
The API for Specifying Formatters
I don't like plists, but I chose to use one because I couldn't figure out a way to get access to arguments passed on the command line to
xcodebuild
. It would be much nicer to users if they could execute the following:Any thoughts on how to do this?
Printing to stderr
As far as I know, there is no way to "silence" XCTest output. Therefore, in order to ensure end users can actually parse the Kiwi formatter output, I've decided to redirect their output to a file. I'm not sure if this is the best way to do things. Ideally, I'd like to "silence" XCTest output and instead print the formatter output to stderr.