hwhat is php Unit Tests code example
Example 1: java unit test an api
@Test
public void
givenUserExists_whenUserInformationIsRetrieved_thenRetrievedResourceIsCorrect()
throws ClientProtocolException, IOException {
HttpUriRequest request = new HttpGet( "https://api.github.com/users/eugenp" );
HttpResponse response = HttpClientBuilder.create().build().execute( request );
GitHubUser resource = RetrieveUtil.retrieveResourceFromResponse(
response, GitHubUser.class);
assertThat( "eugenp", Matchers.is( resource.getLogin() ) );
}
Example 2: node test unit
var assert = require('assert');
describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present', function() {
assert.equal([1, 2, 3].indexOf(4), -1);
});
});
});