Abhishek SIngh
Abhishek SIngh

Reputation: 23

Verify file is successfully downloaded using assertion

File is getting download in jmeter bin folder from 'Save Responses to a file' assertion.

I'm not able to verify the downloaded file, Is there any assertion available other than MD5Hex Assertion or I need to write JAVA/Groovy code?

Upvotes: 0

Views: 546

Answers (2)

Ori Marko
Ori Marko

Reputation: 58822

You can check using notExists with more readable version

import java.nio.file.*;
if (Files.notExists(Paths.get("Bulk.pdf"))) {

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 168122

If you need to check file presence you can add a JSR223 Assertion and use the following code assuming File.exists() function :

if (!new File('Bulk.pdf').exists()) {
    AssertionResult.setFailure(true)
    AssertionResult.setFailureMessage('File is absent') 
}

If the file will not be present you will get an error message like:

enter image description here

More information: Scripting JMeter Assertions in Groovy - A Tutorial

Upvotes: 2

Related Questions