开发者

UITesting using GHunit

开发者 https://www.devze.com 2023-02-02 12:40 出处:网络
hi is there开发者_StackOverflow any tutorial or Document availablefor GUI Testing using GHunit. and in one case for server interaction . i want to write test case by passing some false as well as rig

hi is there开发者_StackOverflow any tutorial or Document available for GUI Testing using GHunit. and in one case for server interaction . i want to write test case by passing some false as well as right Input value to server and then check server response on basic of input . i have this functionality in main project . so any idea how to write test case for server interaction


Testing asynchronous behavior in a unit testing framework is going to be difficult because at that point you're writing an integration test rather than a unit test. That's not to say that these components cannot be tested but rather than a unit test should not try to test them end to end.

For UI elements you can test that they are created, you can test that they contain the values you expect, you can test that when you interact with them the correct action occurs (ie an IBAction method is called, the expected view controller is pushed onto the current navigation controller) but you should not need to step through asynchronous actions like animations or view controller transitions in a single test.

For network requests you can test that a class sends the data you expect it to send and you can separately test that the class takes appropriate action when different types of data are returned. In both cases you can replace the actual network connection with a mock or fake instead of actually connecting to the remote server. Additionally you shouldn't need to test both sending and receiving data in the same test.

Your tests should be testing your code, not that UIKit can animate views or that NSURLConnection can send and receive data so design your tests to actually test your logic and stub out your tested code's external dependencies.

That said GHUnit does provide GHAsyncTestCase which allows you to write tests which will wait for certain types of asynchronous behavior.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号