Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLalit Bagga
3,120 PointsUsing espresso to test internal HTTP request methods
Hi, I choose espresso to start testing async request . One of the problems I found is how do I wait for a response and then start another test. I just wanted to test internal function because UI could be changed but internal functions(API) will remain same. So is there any way so that I start the first test and then wait until I get a response and then start another one. for example
@Test()
public void test_createUser( ) {
new HttpRequest.createUser(new HttpCallback() {
@override
onSuccess() {
//Should wait here
}
})
@Test()
pubic void test_sendMessage() {
//this method should only run after test_createUser got response
}
}
1 Answer
Ben Deitch
Treehouse TeacherHey Lalit! One thing you could do would be to just call your send message test from within the onSuccess method. Though really the create user test should only test whether or not a user was created successfully. If you need a user for the send message test to run correctly, you should probably create a mock user.
Lalit Bagga
3,120 PointsLalit Bagga
3,120 Pointsyes. I was thinking that too to mock the user. Thanks for clearing this out