Skip to content
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

XcodeServerEndpoints.createRequest tests #84

Conversation

pmkowal
Copy link
Contributor

@pmkowal pmkowal commented Jul 25, 2015

Hey, I added three tests for createRequest method, but I don't have a clue how to 100% cover the XcodeServerEndpoints class.
Please take a look.

Btw. I have one proposition regarding XcodeServer class.
I would move the code below (from sendRequestWithMethod method) to createRequest method, because createRequest method can figure out HTTP.Method directly from its parameter. What do you think?

var allParams = [
    "method": method.rawValue
]

//merge the two params
if let params = params {
    for (key, value) in params {
        allParams[key] = value
    }
}

@buildasaur
Copy link
Collaborator

Result of Integration 1

Duration: 1 minute and 5 seconds
Result: Perfect build! All 48 tests passed. 👍
Test Coverage: 51%.

@cojoj
Copy link
Contributor

cojoj commented Jul 25, 2015

@pmkowal can you provide a screenshot of test coverage form XcodeServerEndpoints class?

@pmkowal
Copy link
Contributor Author

pmkowal commented Jul 25, 2015

here you go @cojoj:

testcoverage

@cojoj
Copy link
Contributor

cojoj commented Jul 25, 2015

Nah, the test coverage in code... You know, this fancy indicators showing which lines has been tested 😉

@pmkowal
Copy link
Contributor Author

pmkowal commented Jul 25, 2015

@cojoj are you concerned with buildasaur result of integration?

@cojoj
Copy link
Contributor

cojoj commented Jul 25, 2015

Nope, just want to see coverage and give you ans answer to

but I don't have a clue how to 100% cover the XcodeServerEndpoints class

@pmkowal
Copy link
Contributor Author

pmkowal commented Jul 25, 2015

Cool, I didn't look at it, thx @cojoj

linescoverage

@pmkowal
Copy link
Contributor Author

pmkowal commented Jul 25, 2015

Ok, I know now how to test authorization part, but do you have idea how to test body part?

@cojoj
Copy link
Contributor

cojoj commented Jul 25, 2015

Great I was just writing about his authorization part but if you know how to solve this good for you! 🍹

Now, the body part... It'll be used [mostly] for POST actions. In that case you have to provide a body parameter to createRequest(). To fully check this you'll have to provide a valid JSON and in that case try wil pass and everything will succeed. To cover rest you'll have to provide a failbale JSON which will crash NSJSONSerialization.dataWithJSONObject()

Hope you get me 😉

@pmkowal
Copy link
Contributor Author

pmkowal commented Jul 25, 2015

The point is tried to provide failbale JSON, but I couldn't figure it out 😄, because we can use only [String: String] as body param.

@pmkowal
Copy link
Contributor Author

pmkowal commented Jul 25, 2015

@cojoj ...and with authorization I would create another instance of XcodeServerEndpoints with different config. Do you have other ideas?

@cojoj
Copy link
Contributor

cojoj commented Jul 25, 2015

Exactly... That's what I've been struggling with too 😕
One way is to provide a malformed String but right now I can't think of any... Leaving code like this without a coverage is a bummer but I guess right now we have no other choice. Maybe @czechboy0 have a neat solution to this? 😜


You can move XcodeServerEndpoint to a property and mark it as var so later in test cases you can simply replace config.

@cojoj
Copy link
Contributor

cojoj commented Jul 25, 2015

I'd be great if we have read access to Foundation... You'd simply check what Apple understands under failable JSON. Right now IDK... ¯_(ツ)_/¯

@pmkowal
Copy link
Contributor Author

pmkowal commented Jul 25, 2015

You can move XcodeServerEndpoint to a property and mark it as var so later in test cases you can simply replace config

I was rather thinking of creating another XcodeServerEndpoints in this particular method, because replacing serverConfig could break other tests imo. The seond thing is we cannot exchange serverConfig since it is declared as a let.

I'd be great if we have read access to Foundation... You'd simply check what Apple understands under failable JSON. Right now IDK... ¯_(ツ)_/¯

😁

@cojoj
Copy link
Contributor

cojoj commented Jul 25, 2015

Oh okay... If it's let you have to create instance of XcodeServerEnspoints for each test case.

@buildasaur
Copy link
Collaborator

Result of Integration 2

Duration: 52 seconds
Result: Perfect build! All 49 tests passed. 👍
Test Coverage: 52%.

@pmkowal
Copy link
Contributor Author

pmkowal commented Jul 25, 2015

ok @cojoj authorization part updated.

czechboy0 pushed a commit that referenced this pull request Jul 25, 2015
…uest-tests

XcodeServerEndpoints.createRequest tests
@czechboy0 czechboy0 merged commit eefef5b into buildasaurs:swift-2 Jul 25, 2015
@czechboy0
Copy link
Member

Great stuff, thanks @pmkowal!

@pmkowal
Copy link
Contributor Author

pmkowal commented Jul 25, 2015

👍

@pmkowal pmkowal deleted the xcode-server-endpoints-create-request-tests branch September 12, 2015 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants