Validating if the mocked function was called

  • 17
    Jul

    Validating if the mocked function was called

    Mockito provides “Verify()” which can be used to validate if mock object’s function was called with proper arguments. verify() can be used to verify that a mocked object #...

    Read More
  • 17
    Jul

    Read the excel data as HashMap>

    Following code snippet can be used to read an entire Excel file as HashMap import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import...

    Read More
  • 16
    Jul

    Validating object type created with Mockito

    Following code snippet demonstrates Mocking an Interface with and validating it’s type. import org.junit.Test; import static org.mockito.Mockito.*; import static org.junit.Assert.assertTrue; interface Car { boolean needsFuel(); double getEngineTemperature(); void driveTo(String...

    Read More
  • 16
    Jul

    Mockito spy() – mocking and using an object at same time..

    If your test method is designed to mock a service under implementation and at same time there is another method which need to use an object of same class,...

    Read More
  • 16
    Jul

    Lifecycle of a Mockito test

    Lifecycle of Mock objects Mockito allows execution of tests for classes with dependency under development (or external databases whose access is not available at run-time). Creating and accessing mock...

    Read More
  • 16
    Jul

    How to automation if a feature is in development

    Overcoming Automation challenges in an Agile development ======================================================== During development phase when a feature is still not ready for automation, general expectations is to take up automation once feature...

    Read More
  • 13
    Jul

    Setting connection timeout and other timeouts with HttpClient

    Following code snippet demonstrates how to configure “connection-timeout”, “socket-timeout” with HttpClient package RestAssured; import java.io.IOException; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; public class ConnectionTimeout {...

    Read More
  • 13
    Jul

    Request.setEntity() to attach an XML load to a REST request via HttpClient

    Following code demonstrates how to attach a XML Load while sending request to server for processing // Payload for XML Request String xmlLoad = “ Jackychan 999999999“; HttpClient httpClient...

    Read More
  • 13
    Jul

    Processing response with response.entity in HttpClient

    import java.io.IOException; import java.io.InputStream; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; public class ClientConnectionRelease { public final static void main(String args) throws Exception { CloseableHttpClient httpclient...

    Read More
  • 13
    Jul

    How to process response from HttpClient

    Following code-snippet demonstrates way to handle Response.entity import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClients;...

    Read More