Skip to content

Files

 
 

unirest-mocks

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Unirest Mocks

About

A series of mocks for use with Unirest for unit testing. The mock clients will not make any real web requests.

Usage

class MyTest {
    @Test
    void expectGet(){
        MockClient mock = MockClient.register();

        mock.expect(HttpMethod.GET, "http://zombo.com")
                        .thenReturn("You can do anything!");
        
        assertEquals(
            "You can do anything!", 
            Unirest.get("http://zombo.com").asString().getBody()
        );
        
        //Optional: Verify all expectations were fulfilled
        mock.verifyAll();
    }
}

Future Enhancements

  • Mocks currently only work with the regular client and not the async engine.
  • Body expectations are limited and do not include forms or files.