-
-
Notifications
You must be signed in to change notification settings - Fork 403
Reusing Single and Multiple Step Files
Anish Jha
- Purpose of a step file
- Using a single Step File
- Purpose of multiple step files
- Using a multiple Step Files as Array
- Conclusion
Step file is a single json file which consist of one common api/step.Suppose when we are writing test for multiple flows and there will be the case where some common api/step needs to execute in more than one flow. So in this scenario instead of writing same api in each flow we can write the step in external file and can reuse in required flows.
To understand it better, lets take an example. Suppose we have two flow flow1 and flow2 and there is a get api call which is common in both. So for get api call instead of writing in both the flow we will create an external step file and reuse this in both.
flow1.json
{
"scenarioName":"flow 1",
"steps":[
{
"name": "api1",
"url": "/api/v1/customers",
"operation": "POST",
"request": {
"body": {
"name":"anish jha",
"age": "25",
"gender": "male",
"email": "anishjha93@gmail.com"
"country": "india",
}
},
"assertions": {
"status":201
}
},
{
"id": "get_customers",
"stepFile": "${JSON.FILE:resource_direcotry/get_customers.json}"
}
}
flow2.json
{
"scenarioName":"flow 2",
"steps":[
{
"name": "api2",
"url": "/api/v1/customers/1",
"operation": "PUT",
"request": {
"body": {
"name":"anish jha",
"age": "25",
"gender": "male",
"email": "anishjha93@gmail.com"
"country": "india",
}
},
"assertions": {
"status":201
}
},
{
"id": "get_customers",
"stepFile": "${JSON.FILE:resource_direcotry/get_customers.json}"
}
}
get_customers.json
{
"name": "get_customers",
"url": "/api/v1/customers/",
"operation": "get",
"request": {
},
"assertions": {
"status":200
}
}
Multiple step file is same as single step file but the only difference is,single step file support one step/api call whereas multiple step file support one or more step/api call.
Lets take an example. Suppose we have two flow flow1 and flow2 and there is a two get api call which is common in both. So for get api call instead of writing in both the flow we will create an external step file and reuse this in both.
flow1.json
{
"scenarioName":"flow 1",
"steps":[
{
"name": "api1",
"url": "/api/v1/customers",
"operation": "POST",
"request": {
"body": {
"name":"anish jha",
"age": "25",
"gender": "male",
"email": "anishjha93@gmail.com"
"country": "india",
}
},
"assertions": {
"status":201
}
},
{
"id": "get_customers",
"stepFile": "${JSON.FILE:resource_direcotry/get_customers.json}"
}
}
flow2.json
{
"scenarioName":"flow 2",
"steps":[
{
"name": "api2",
"url": "/api/v1/customers/1",
"operation": "PUT",
"request": {
"body": {
"name":"anish jha",
"age": "25",
"gender": "male",
"email": "anishjha93@gmail.com"
"country": "india",
}
},
"assertions": {
"status":201
}
},
{
"id": "get_customers",
"stepFile": "${JSON.FILE:resource_direcotry/get_customers.json}"
}
}
get_customers.json
[
{
"name": "get_customers",
"url": "/api/v1/customers/",
"operation": "get",
"request": {
},
"assertions": {
"status":200
}
},
{
"name": "get_customer",
"url": "/api/v1/customer/1",
"operation": "get",
"request": {
},
"assertions": {
"status":200
}
}
]
Look for a working example in the HelloWorld repo (Work in progress, an example to be added in the above repo)
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...