-
-
Notifications
You must be signed in to change notification settings - Fork 397
Home
Use the sidebar on the right for all topics or "Ctrl+f" search for any topic
(For helps and usage- Visit Table of Contents. Visit here for a Quick Introduction to Hassle-Free Declarative Testing)
- Welcome To Zerocode
- Super Easy to Write BDD Tests
- Zerocode Tokens
- No Complexity Involved
- Plug and Play Security Testing
- Beautiful and Useful Reporting
- Easy to Collaborate
- Handy Even For Manual Testers or Architects
- Inspired By
- Contribute
Zerocode helps you to design better Test Cases for your business features, then maintain and update them easily to avoid sleepless nights. It is built on extending the Junit core runners. You simply annotate your test method with JUnit @Test and run like JUnit tests, as well as optionally you can use Suite
Runners for CI builds and env switching. Testing becomes an easy and effortless job due to the simplicity nature of JSON and the native support by popular IDEs e.g. Eclipse /IntelliJ /NetBeans etc with no extra plugin. Super easy !
Zerocode provides built-in tokens that help with your testing ranging from generating random numbers through to accessing system properties, currently Zerocode offers the following tokens:
- LOCALDATE_TODAY
- LOCALDATETIME_NOW
- RANDOM_NUMBER
- RANDOM_STRING_PREFIX
- RANDOM_UUID
- RECORD_DUMP
- STATIC_ALPHABET
- SYSTEM_ENV
- SYSTEM_PROPERTY
- XML_FILE
Verifications/Assertions Tokens:
- CONTAINS.STRING
- CONTAINS.STRING.IGNORECASE
- IS.ONE.OF
- IS.NULL
- IS.NOTNULL
- GT
- LT
- SIZE
- MATCHES.STRING
- LOCAL.DATETIME.AFTER
- LOCAL.DATETIME.BEFORE
Your tests will not be cumbersome and complex anymore. Zerocode makes your tests independent, complete and structured and easily maintainable by the team or the new comers. It enables you to write your API End Point Tests
, Consumer Contract Tests
, End to End Tests
and Performance Tests(Load/Stress)
etc, at the speed of writing JUnit tests with accuracy transparent to all stakeholders.
Zerocode at its core uses simple and powerful libs like Jackson
for JSON assertions, Apache HttpClient
for invoking REST and SOAP APIs, Google Guice
for DI
and Spring style place holders ${JSON Path}
for result assertions. It does not limit you to use Apache HttpClient, it enables you to easily override the framework behaviour with @UseHttpClient
to use e.g. UniRest
HttpClient, RestEasy
HttpClient or any of your custom HttpClient that suits your project needs.
Zerocode gives you out of the box SSL enabled Http Client and SOAP Client along with the optional MIME type converters e.g. XML to JSON if needed to increase test readability. It provides you with the options to configure Corporate Proxy at runtime to allow API invocations via proxies.
Zerocode has built general functionality which enables you to extend and enrich the framework behaviour by simply executing external Java methods to achieve business goals rather than putting every feature into the core framework.
Zerocode prints the request, response into the console as well as to the log file in the /target
folder in a human/business readable format, along with producing granular report in the CSV format
and Interactive Fuzzy Search Enabled Chart report
. You can search and filter
the test report by author
or test-scenario
or test-step
or any relevant matching text making it super easy to trace a step in the context of a scenario or user-journey.
Zerocode aims to make development and testing easier and faster, not harder and slower. Allows both Dev team and Test team to collaborate towards better better quality of the software. Even the managers and BAs can read and understand the tests easily if they want to.
Handy tool even for manual testers dealing with REST api
, SOAP api
and DB integration
tests much more to keep it side by side of Postman rest-client!
Learn how the ZeroCode testing library can make your life easier and writing tests faster by simply putting your thoughts into executable test scenarios and not enforcing you to write boiler plate glue code and sticky wrappers around your tests adding extra overhead/maintenance.
It allows you to override the framework behavior by your own java code which becomes not only reusable but becomes a part of the framework.
See the HelloWorldTest
Because there is a clear and obvious pattern for REST api or SOAP or any other api testing which Zerocode solves efficiently without adding any syntax overhead, that means it makes your testing process very very easy and accurate.
e.g. Your below User-Journey or ACs(Acceptance Criterias) or a scenario,
AC1:
GIVEN- the POST api end point '/api/v1/users' to create an user,
WHEN- I invoke the API,
THEN- I will receive the 201 status with the a user ID and headers
AND- I will validate the response
AC2:
GIVEN- the REST api GET end point '/api/v1/users/${created-User-Id}',
WHEN- I invoke the API,
THEN- I will receive the 200(Ok) status with body(user details) and headers
AND- I will assert the response
translates to the below executable JSON in Zerocode
- Simple and clean !
(See here a full blown CRUD operation scenario with POST, PUT, GET, DELETE example.)
and it is declarative DSL, with the request/response
fields available for the next steps via the JSON Path
.
Then you just stick this into a JSON file named e.g. post_n_get_user_journey_test.json
, anywhere in the test/resources
folder,
and run the code like below by pointing to that JSON file. That's it.
@TargetEnv("github_host.properties")
@RunWith(ZeroCodeUnitRunner.class)
public class MyRestApiTest{
@Test
@JsonTestCase("post_n_get_user_journey_test.json")
public void testPostAndGet_happy() throws Exception {
}
}
Keep in mind: It's simple JSON.
No feature files, no extra plugins, no statements or grammar syntax overhead.
-
HelloWorld Examples and samples are here to download or clone
-
The latest maven dependency can be found here at Maven central - Old releases Maven central - New releases
<dependency>
<groupId>org.jsmart</groupId>
<artifactId>zerocode-rest-bdd</artifactId>
<version>1.3.x</version>
</dependency>
- You can organize and arrange the tests to suit your requirements, by folder/feature/release wise
Test reports are generated into /target
folder every time the tests are run. Sample reports are here format.
Test logs are generated in the console as well as into the log file in a readable JSON format target/logs/zerocode_rest_bdd_logs.log
. In case of a test failure it exactly lists which field or fields didn't match with their JSON Path in a tree view.
Note-
Every step is assigned with an auto generated STEP-ID to relate request with response of that step.
e.g. If test passed:
--------- CORRELATION-ID: e6170365-94e7-49dc-a1a3-5e102468acc2 ---------
requestTimeStamp:2017-12-20T10:00:48.840
step:get_same_employee
url:http://localhost:9999/api/testing/v1/persons/UK1001
method:GET
request:
{ }
--------- CORRELATION-ID: e6170365-94e7-49dc-a1a3-5e102468acc2 ---------
Response:
{
"status" : 200,
"headers" : {
"Date" : [ [ "Wed, 20 Dec 2017 03:00:48 GMT" ] ],
"Last-Modified" : [ [ "Wed, 20 Dec 2017 03:00:48 GMT" ] ],
"Transfer-Encoding" : [ [ "chunked" ] ],
"Content-Type" : [ [ "application/json" ] ],
"Connection" : [ [ "keep-alive" ] ]
},
"body" : {
"id" : "UK1001",
"name" : "Bobby Lion",
"addresses" : [ {
"line1" : "HOME, AECS Layout, ZIP-56094"
}, {
"line1" : "OFFICE, Newark, ZIP-730290"
} ]
}
}
*responseTimeStamp:2017-12-20T10:00:48.847
*Response delay:7.0 milli-secs
---------> Assertion: <----------
{
"status" : 200,
"body" : {
"id" : "UK1001"
}
}
-done-
If test failed:
--------- CORRELATION-ID: 8ad5c1fe-31cb-4e46-a8ba-7500a00c2199 ---------
requestTimeStamp:2017-12-20T10:02:01.163
step:get_an_employee_detail
url:http://localhost:9999/api/testing/v1/persons/UK1001
method:GET
request:
{ }
--------- CORRELATION-ID: 8ad5c1fe-31cb-4e46-a8ba-7500a00c2199 ---------
Response:
{
"status" : 200,
"headers" : {
"Date" : [ [ "Wed, 20 Dec 2017 03:02:01 GMT" ] ],
"Last-Modified" : [ [ "Wed, 20 Dec 2017 03:02:01 GMT" ] ],
"Transfer-Encoding" : [ [ "chunked" ] ],
"Content-Type" : [ [ "application/json" ] ],
"Connection" : [ [ "keep-alive" ] ]
},
"body" : {
"id" : "UK1001",
"name" : "Bobby Lion",
"addresses" : [ {
"line1" : "HOME, AECS Layout, ZIP-56094"
}, {
"line1" : "OFFICE, Newark, ZIP-730290"
} ]
}
}
*responseTimeStamp:2017-12-20T10:02:01.315
*Response delay:152.0 milli-secs
---------> Assertion: <----------
{
"status" : 400,
"body" : {
"id" : "UK1001"
}
}
-done-
java.lang.RuntimeException: Assertion failed for :-
[test_get_request_response_rainy_scene.json]
|
|
+---Step --> [get_an_employee_detail]
Failures:
---------
Assertion path '$.status' with actual value '200' did not match the expected value '400'
Pyresttest's JSON/YAML based test-DSL inspired many of Zerocode's Http DSL and test-config features.
Apache JMeter's intuitive load configuration inspired various Zerocode's declarative Load Testing DSL.
SkyScreamer's lenient mode smart JSON comparison inspired Zerocode's lenient JSON comparison feature.
Spring's popular token/placeholder resolver inspired Zerocode's runtime token/placeholder resolver feature.
Jupiter Junit5's easy and declarative approach to parameterized testing inspired Zerocode's parameterized testing feature.
Powered by open-source software.
IDE Credits
Raise issues and contribute to improve zerocode by becoming a contributor yourself.
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...