-
-
Notifications
You must be signed in to change notification settings - Fork 397
External JSON file as reusable content
authorjapps edited this page Mar 1, 2019
·
4 revisions
The following examples shows how to reuse an external JSON file or files in the Zerocode test cases
From this version onwards, Zerocode supports this feature. But there is a usage warning around it not to overuse this feature.
Dependency:
<dependency>
<groupId>org.jsmart</groupId>
<artifactId>zerocode-tdd</artifactId>
<version>check-latest-in-readme-github</version>
</dependency>
Here is a sample test-case with external file as JSON content.
{
"scenarioName": "POST API - File json as response content - Reuse body",
"steps": [
{
"name": "create_emp",
"url": "/api/v1/employees",
"operation": "POST",
"request": {
"body" : "${JSON.FILE:reusable_content/request/request_body.json}"
},
"assertions": {
"status": 201
}
},
{
"name": "get_user_details",
"url": "/api/v1/employees/${$.create_emp.response.body.id}",
"operation": "GET",
"request": {
},
"assertions": {
"status": 200,
"body" : "${JSON.FILE:reusable_content/response/response_body.json}"
}
}
]
}
where the
request_body.json
{
"name": "Emma",
"surName": "Norton"
}
response_body.json
{
"id": 39001,
"ldapId": "emmanorton",
"name": "Emma",
"surName": "Norton"
}
You can pick the handy examples from our HelloWorld repo (as shown below) :
- Try to keep the test cases as independent possible. Do not create too much dependencies on external files which will add unnecessary complexity to the project.
- The complexity could be in terms project maintenance or interpreting the test case itself. Traversing around the tests are painful and we pay a price for it if they not readable.
- We should use the IDE features which now a days, makes it a lot easier in terms of dealing with JSON contents to keep the testing life cycle simple n clean.
Visit the Zerocode Documentation Site for all things.
-
User's Guide
-
Matchers
-
Zerocode Value Tokens
-
YAML DSL
-
Http Testing
-
Kafka Testing
- Introduction
- Produce, consume proto message
- Produce raw message
- Consume raw message
- Produce JSON message
- Consume JSON message
- Produce and consume XML message
- Kafka - consume the latest message or n latest messages
- Produce avro message
- Consume avro message
- KSQL in action
- Produce multiple records
- Produce from file
- Produce to a partition
- Produce and consume records with headers
- Produce n assert partition ack
- Comsume and dump to file
- commitSync vs commitAsync
- Overriding config inside a test
- Chosing String or Int or Avro Serializer
- Chosing String or Int or Avro Deserializer
- Attaching timestamp during load
- Default timestamp provided by Kafka
- Consume and assert avro schema metadata
- Error handling - produce via avro schema
- Sorting Kafka records consumed
-
DB Testing
-
Kotlin Testing
-
Performance Testing - Load and Stress
- Performance Testing - via awesome JUnit runners
- Load Vs Stress generation on target application
- Run a single test or a scenario in parallel
- Run multiple test scenarios in parallel - Production load simulation
- Dynamically change the payload for every request
- Analytics - Useful report(s) or statistics
-
Parameterized Testing
-
Docker
-
More+
-
Extensions
-
JUnit5 Jupiter Test
-
Questions And Answers(FAQ)
- What is Zerocode testing?
- SSL http https connections supported?
- How to assert array size Greater-Than Lesser-Than etc?
- How to invoke POST api?
- How to assert custom headers of the response?
- How to pass custom security token into the request header?
- When to use JUnit Suite runner and when Zerocode Package runner?
- How to execute DB SQL and assert?
- How to handle Http response other than utf-8 e.g. utf-16 or utf-32 ?
- Random Number Generator Placeholders Usages and Limits
- Automation tests for Zerocode lib itself
- Picking a leaf value from the array matching JSON Path
- Array assertions made easy, incl. size and element finder
-
Read Our Blogs
- Top 16 Open Source API Testing Tools For REST & SOAP Services - joecolantonio (Lists popular tools - Globally)
- OAuth2 Test Automation - DZone 2min Read
- Zero defect APIs - Build Pipe Line - Medium 10 min Read
- Develop ZeroDefect API's with ZeroCode! - Extreme Portal ( A must read for all developers and test engineers) 10min Read
- Performance testing using JUnit and maven - Codeproject 10 min Read
- REST API or SOAP End Point Testing - Codeproject 10min Read
- DZone- MuleSoft API Testing With Zerocode Test Framework - DZone 5min Read
- Testing need not be harder or slower, it should be easier and faster - DZone 5 min Read
- Kotlin Integration Testing simplified via Zerocode - Extreme portal 10 min Read
- and More...