Class DslDummySampler

  • All Implemented Interfaces:
    DslTestElement, DslSampler, BaseThreadGroup.ThreadGroupChild

    public class DslDummySampler
    extends BaseSampler<DslDummySampler>
    Allows using JMeter Dummy Sampler plugin to emulate other samples and ease testing post processors and other parts of a test plan.

    By default, this element is set with no request, url, response code=200, response message = OK, and response time with random value between 50 and 500 milliseconds. Additionally, emulation of response times (through sleeps) is disabled to speed up testing.

    Since:
    0.46
    • Field Detail

      • responseBody

        protected String responseBody
      • successful

        protected boolean successful
      • responseCode

        protected String responseCode
      • responseMessage

        protected String responseMessage
      • responseTime

        protected String responseTime
      • simulateResponseTime

        protected boolean simulateResponseTime
      • requestBody

        protected String requestBody
    • Constructor Detail

      • DslDummySampler

        public DslDummySampler​(String name,
                               String responseBody)
    • Method Detail

      • successful

        public DslDummySampler successful​(boolean successful)
        Allows generating successful or unsuccessful sample results for this sampler.
        Parameters:
        successful - when true, generated sample result will be successful, otherwise it will be marked as failure. When not specified, successful sample results are generated.
        Returns:
        the sampler for further configuration or usage.
      • responseCode

        public DslDummySampler responseCode​(String code)
        Specifies the response code included in generated sample results.
        Parameters:
        code - defines the response code included in sample results. When not set, 200 is used.
        Returns:
        the sampler for further configuration or usage.
      • responseMessage

        public DslDummySampler responseMessage​(String message)
        Specifies the response message included in generated sample results.
        Parameters:
        message - defines the response message included in sample results. When not set, OK is used.
        Returns:
        the sampler for further configuration or usage.
      • responseTime

        public DslDummySampler responseTime​(Duration responseTime)
        Specifies the response time used in generated sample results.
        Parameters:
        responseTime - defines the response time associated to the sample results. When not set, a randomly calculated value between 50 and 500 milliseconds is used.
        Returns:
        the sampler for further configuration or usage.
      • responseTime

        public DslDummySampler responseTime​(String responseTime)
        Same as responseTime(Duration) but allowing to specify a JMeter expression for evaluation.

        This is useful when you want response time to be calculated dynamically. For example,

        ${__Random(50, 500)}
        Parameters:
        responseTime - specifies the JMeter expression to be used to calculate response times, in milliseconds, for the sampler.
        Returns:
        the sampler for further configuration or usage.
        Since:
        1.0
        See Also:
        responseTime(Duration)
      • simulateResponseTime

        public DslDummySampler simulateResponseTime​(boolean simulate)
        Specifies if used response time should be simulated (the sample will sleep for the given duration) or not.

        Having simulation disabled allows for really fast emulation and trial of test plan, which is very handy when debugging. If you need a more accurate emulation in more advanced cases, like you don't want to generate too many requests per second, and you want a behavior closer to the real thing, then consider enabling response time simulation.

        Parameters:
        simulate - when true enables simulation of response times, when false no wait is done speeding up test plan execution. By default, simulation is disabled.
        Returns:
        the sampler for further configuration or usage.
      • url

        public DslDummySampler url​(String url)
        Specifies the URL used in generated sample results.

        This might be helpful in scenarios where extractors, pre-processors or other test plan elements depend on the URL.

        Parameters:
        url - defines the URL associated to generated sample results. When not set, an empty URL is used.
        Returns:
        the sampler for further configuration or usage.
      • requestBody

        public DslDummySampler requestBody​(String requestBody)
        Specifies the request body used in generated sample results.

        This might be helpful in scenarios where extractors, pre-processors or other test plan elements depend on the request body.

        Parameters:
        requestBody - defines the request body associated to generated sample results. When not set, an empty body is used.
        Returns:
        the sampler for further configuration or usage.