authorjapps / zerocode

A community-developed, free, opensource, automated testing framework for microservices APIs, Kafka(Data Streams) and Load testing. Zerocode Open Source enables you to create, change and maintain your automated test scenarios via simple JSON or YAML files. Visit documentation below:
https://zerocode-tdd.tddfy.com
Apache License 2.0
884 stars 385 forks source link

Asset a specific message when multiple messages flowing through the brokers or topics #222

Closed nirmalchandra closed 5 years ago

nirmalchandra commented 5 years ago

Created from #220

2. When testing in real environment, there will be multiple messages flowing through the brokers/topics. How can zerocode validate/asset a specific response? Ans: Use Json Path to look for a perticular message or a record key or value. Very easy! e.g.

When you have consume multiple records from a topic, that means you receive an array of records as the response. Then you can assert this way explained in the readme-file.

Where is this JSON path is applied ? In JUNIT or within Zerocode JSON config ?

For example, my test below keeps on failing. In the log, instead of just consuming the messages with the ids I have specified below. It consumes the whole array of 10 messages.

{
    "scenarioName": "consume a JSON message with id_5 & id_9 out of 10 messages produced on topic_A",
    "steps": [

        {
            "name": "consume_step",
            "url": "kafka-topic:topic_A",
            "operation": "consume",
            "request": {
                "consumerLocalConfigs": {
                    "recordType": "JSON",
                    "commitSync": true,
                    "showRecordsConsumed": true,
                    "maxNoOfRetryPollsOrTimeouts": 3
                }
            },
            "assertions": {
                "records": [
                    {
                        "key": "id_5",
                        "value": {

                            "TEST": "Test Val0"
                        }
                    },
                    {
                        "key": "id_9",
                        "value": {

                            "TEST": "Test Val9"
                        }
                    }
                ]
            }
        }
    ]
}
authorjapps commented 5 years ago

Hello @tghani93, Do you still want us to look at it?

tghani93 commented 5 years ago

@authorjapps - thank you for your help so far. Just one more question: security. Could you point me to some resources / documentation where I can read about library (zerocode's) security?

TIA

authorjapps commented 5 years ago

Just trying to understand - Are you looking for how Zerocode supports/invokes secured APIs e.g. Https / OAuth2 / SAML / Kafka etc? or anything else in general ?

If you could be specific, then we can try to answer...

tghani93 commented 5 years ago

Yes secure APIs as you mentioned and in general as well :) I am planning on doing a blog about Zerocode also, so wanted to obtain a deeper understanding as well.

tghani93 commented 5 years ago

And please excuse my ignorance & naivety, how does Zerocode compares to: https://www.testcontainers.org/ The reason I am asking is as above that I an trying to push zerocode as first preference and would like an expert opinion. TIA

authorjapps commented 5 years ago

Yes secure APIs as you mentioned and in general as well :) I am planning on doing a blog about Zerocode also, so wanted to obtain a deeper understanding as well.

That sounds cool. 👍

@UseHttpClient(CustomHttpClient.class)
authorjapps commented 5 years ago

And please excuse my ignorance & naivety, how does Zerocode compares to: https://www.testcontainers.org/ The reason I am asking is as above that I an trying to push zerocode as first preference and would like an expert opinion. TIA

Sorry mate for the delay. These two are very different tools for different purposes not worth comparing.

testcontainers.org >>Mostly for anything ... that can run in a Docker container.

Zerocode is for

in a declarative way reducing the hassles to zero for Developers/Testers.

But on the feature-comparison front- We are in the process of collecting the feedback/data from our customers to capture why they are migrating from their existing tools to Zerocode e.g.

  1. From Postman(collections) to Zerocode
  2. From other Step-Definition based BDD tools to Zerocode etc.

We will spin up a Wiki page or a Google doc once that's ready. That might throw some light on this line.

But our advise will be choose a tool/lib/framework

Hope this helps!

Also we are excited to see your blog when it's ready ❗️

and wish you good luck 🙏

tghani93 commented 5 years ago

@authorjapps , very grateful for your responses and pointers. Will have keep you posted on the blog! :)

tghani93 commented 5 years ago

@authorjapps, just letting you know that I will be recycling some of your awesome pointers above in the blog!! :)

authorjapps commented 5 years ago

Sounds cool mate. 👍 Please try to keep the blog precise/short, easily understandable for first timers as well as experience developer/testers :-) Good luck!