Class ResponseFileSaver

  • All Implemented Interfaces:
    DslTestElement, DslTestPlan.TestPlanChild, DslListener, BaseSampler.SamplerChild, MultiLevelTestElement, BaseThreadGroup.ThreadGroupChild

    public class ResponseFileSaver
    extends BaseListener
    Generates one file for each response of a sample/request.

    This element is dependant of the scope: this means that if you add it at test plan level it will generate files for all samplers in test plan, if added at thread group level then it will generate files for samplers only in the thread group, and if you add it at sampler level it will generate files only for the associated sampler.

    By default, it will generate one file for each response using the given (which might include the directory location) prefix to create the files and adding an incremental number and an extension according to the response mime type.

    Eg:

    responseFileSaver("responses/resp")
    will generate files like "responses/resp1.json".

    Both the incremental number and the file extension can be disabled setting autoNumber(boolean) and autoFileExtension(boolean) to false.

    Since:
    0.13
    • Field Detail

      • fileNamePrefix

        protected String fileNamePrefix
      • autoNumber

        protected boolean autoNumber
      • autoFileExtension

        protected boolean autoFileExtension
    • Constructor Detail

      • ResponseFileSaver

        public ResponseFileSaver​(String fileNamePrefix)
    • Method Detail

      • autoNumber

        public ResponseFileSaver autoNumber​(boolean autoNumber)
        Specifies whether, or not, to append an auto incremental number to each generated response file name.

        WARNING: if you disable this feature you might not get the files for all generated responses (due to potential file name collision and file rewrite). Consider using some jmeter expression in file name to avoid file name collisions and overrides (eg: "responses/${__threadNum}-${__jm__Thread Group__idx}").

        Parameters:
        autoNumber - specifies to add the auto incremental numbers to the file when set to true. By default, this is set to true.
        Returns:
        the ResponseFileSaver for further configuration or usage.
        Since:
        1.27
      • autoFileExtension

        public ResponseFileSaver autoFileExtension​(boolean autoFileExtension)
        Specifies whether, or not, to append an automatic file extension to the file name.

        The automatic file extension is solved according to the response MIME type.

        Parameters:
        autoFileExtension - specifies to use the automatic file type extension when set to true. By default, is set ti true.
        Returns:
        the ResponseFileSaver for further configuration or usage.
        Since:
        1.27