Skip to main content

Posts

Showing posts from January, 2022

Test Data Supplier (TestNG DataProvider wrapper)

  Test Data Supplier (TestNG DataProvider wrapper) If you are a big fan of Stream and Collection API for data manipulation in the modern Java world, give a shot to this library that contains TestNG DataProvider wrapper (as of writing this blog, the latest version is based on TestNG 7.8.0) which helps to supply test data in a more flexible way. Supported return types Collection Map Entry Object[] double[] int[] long[] Stream / StreamEx Tuple A single Object of any common or custom type As it can return StreamEx, it gives you more power to play with flatmap, indices, transposing, etc. You can find more details and sample Gradle/Maven projects on their official GitHub repository page :  https://github.com/sskorol/test-data-supplier Enjoyed reading this article? Please share the knowledge with your friends and colleagues.

Test Automation Fundamentals

 

How to upload a pdf file using REST Assured?

 If you use this code as mentioned in few other blogs and videos:   Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "multipart/form-data"); byte[] fileContent = FileUtils.readFileToByteArray(new File(filePath)); RestAssured.given().headers(headers).body(fileContent).post(url);   There are high chances that you will get errors related to content-type or "400 - Request is not a multipart request". So, the solution is to use: .multiPart("file", new File("/path/to/file"),"application/pdf"). Please note that I have used "application/pdf" as 3rd param in the multiPart method and this value should be passed as per the file type that you are uploading like for the png file it should be "application/octet-stream", for JSON file it should be "application/JSON". multiPart is an overloaded method that can take max 3 parameters:   a)