Confused
Confused

Reputation: 3926

XCTest UITesting - Import test cases and export test case results

I'm writing UITest cases to my application using XCTest. Some test cases needs some input.

Consider that I'm writing test case of my login page. Login page needs Username & Password. I should check invalid username, invalid password, empty fields, valid username and password all these scenarios. These inputs (Username & Password with various combination) was set in the test classes.

I want to separate this inputs from test classes. I should give outputs from outside. So I created a plist file, which includes username & password combination. I imported plist file's data and gave it to the test cases.

Question: Is this approach fine? Or should I do any other way to pass inputs to my test cases?

Coming to the output part, after the test cases was completed, we can see the test results in "Test Navigator" panel. (Passed results are shown with green tick mark, where the red one shows for failed test case).

I want to export these results from Xcode, so that I may present the results in a webpage, or I may want to print results in a text file, etc.

Question: Is this possible? If yes, can someone explain on it?

Just confused!!

Upvotes: 1

Views: 1470

Answers (2)

Confused
Confused

Reputation: 3926

After some research, I wrote an util class that can take plist, json object, txt file as inputs. It will convert them into the NSDictionary then it will use the needed data as inputs.

For the output part, I am using OSX Server. The build-in outputs are more elegant than my expectation. Thanks to Apple!!

Upvotes: 0

itsViksIn
itsViksIn

Reputation: 702

You can use either plist or Json file for the parameterization of the tests. To parse the output you can use xcpretty which is widely used formatter for xcodebuild, it generates the output as Unit-Style XML or html as well. You can trigger the tests from command line using xcodebuild test and pipe the output to xcpretty

Upvotes: 2

Related Questions