Job Opening for Tester of Web Apps at Moolya >>Could you spot this? This is intentional!

Testing on the Toilet: Exercise Service Call Contracts in Tests

This article was adapted from a Google Testing on the Toilet (TotT) episode. You can download a printer-friendly version of this TotT episode and post it in your office.By Ben YuThe following test mocks out a service call to CloudService.  Does the test provide enough confidence that the service call is likely to work?@Test public void uploadFileToCloudStorage() { when(mockCloudService.write( WriteRequest.newBuilder().setUserId(“testuser”).setFileType(“plain/text”)...)) .thenReturn(WriteResponse.newBuilder().setUploadId(“uploadId”).build()); CloudUploader cloudUploader = new CloudUploader(mockCloudService); Uri uri = cloudUploader.uploadFile(new File(“/path/to/foo.txt”)); // The uploaded file URI contains the user ID, file type, and upload ID. (Or does it?) assertThat(uri).isEqualTo(new Uri(“/testuser/text/uploadId.txt”));Lots of...


Share |

Published By: Google Testing Blog - Tuesday, 27 November