Summer of Code/2014/Activity Unit Tests: Difference between revisions
AneeshDogra (talk | contribs) No edit summary |
AneeshDogra (talk | contribs) No edit summary |
||
| Line 52: | Line 52: | ||
assert(result.get_text() == "1") | assert(result.get_text() == "1") | ||
Another complex testing domain we need to care about is network dependent ones. For example to test the chat API's receive method we'd have to actually send in a message from a different chat activity to this one and then test if its working. This isn't a viable approach to test network based triggers. Instead we'd have to mock up the network bits. By that I mean if we have a ChatActivity class that runs the receive method on the "message received" event we'd make a mock class and change the trigger to a manual one. | Another complex testing domain we need to care about is network dependent ones. For example to test the chat API's UI, we'd have to send in a few messages and check if they are displayed. To invoke the receive method we'd have to actually send in a message from a different chat activity to this one and then test if its working. This isn't a viable approach to test network based triggers. Instead we'd have to mock up the network bits. By that I mean if we have a ChatActivity class that runs the receive method on the "message received" event we'd make a mock class and change the trigger to a manual one. Just run the receive method with some test/dummy data and check if the UI is updated accordingly. | ||
To further explain my approach I'd like to take an example from the Chat Activity. In the chat activity class: | To further explain my approach I'd like to take an example from the Chat Activity. In the chat activity class: | ||