{"id":21758913,"url":"https://github.com/anshul-sonpure/karate_tutorial","last_synced_at":"2025-08-12T05:07:50.123Z","repository":{"id":156022452,"uuid":"554226191","full_name":"Anshul-Sonpure/Karate_Tutorial","owner":"Anshul-Sonpure","description":"Karate framework for API testing.","archived":false,"fork":false,"pushed_at":"2022-10-19T13:40:45.000Z","size":316,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-21T04:14:22.695Z","etag":null,"topics":["apitesting","bdd","karate-framework","karate-tests","testing"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Anshul-Sonpure.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-19T13:09:37.000Z","updated_at":"2023-05-22T04:19:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"d15b23ad-037b-46cf-81a0-f2c2a8e7c5f7","html_url":"https://github.com/Anshul-Sonpure/Karate_Tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Anshul-Sonpure/Karate_Tutorial","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anshul-Sonpure%2FKarate_Tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anshul-Sonpure%2FKarate_Tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anshul-Sonpure%2FKarate_Tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anshul-Sonpure%2FKarate_Tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Anshul-Sonpure","download_url":"https://codeload.github.com/Anshul-Sonpure/Karate_Tutorial/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anshul-Sonpure%2FKarate_Tutorial/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270005591,"owners_count":24510939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apitesting","bdd","karate-framework","karate-tests","testing"],"created_at":"2024-11-26T11:24:35.585Z","updated_at":"2025-08-12T05:07:50.092Z","avatar_url":"https://github.com/Anshul-Sonpure.png","language":"HTML","readme":"# Karate_Tutorial\nHi All,\nWelcome to this Karate API testing tutorial.\nThis repo is all about how Karate can be used to test Restful API.\nIn testscripts folder I have written feature file for GET,POST,PUT and DELETE request.\nTo do hands-on, you can clone the repo, open the project in IDE and navigate to testscripts folder.\nYou can either run the feature file or you can execute all the test scripts using TestRunner class.\nNow talking about Karate and BDD Framework.\n\n## Karate and BDD\nKarate is built on top of Cucumber, another BDD testing framework, and shares some of the same concepts. One of these is the use of a Gherkin file, which describes the tested feature. However, unlike Cucumber, tests aren't written in Java and are fully described in the Gherkin file.\n\nA Gherkin file is saved with the “.feature” extension. It begins with the Feature keyword, followed by the feature name on the same line. It also contains different test scenarios, each beginning with the keyword Scenario and consisting of multiple steps with the keywords Given, When, Then, And, and But.\n\n## Features\n- Java knowledge is not required and even non-programmers can write tests\n- Scripts are plain-text, require no compilation step or IDE, and teams can collaborate using Git / standard SCM\n- Based on the popular Cucumber / Gherkin standard - with IDE support and syntax-coloring options\n\n\n\n## Maven Dependencies\n\nTo make use of Karate in a Maven project, we need to add the karate-apache dependency to the pom.xml:\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.intuit.karate\u003c/groupId\u003e\n    \u003cartifactId\u003ekarate-apache\u003c/artifactId\u003e\n    \u003cversion\u003e0.6.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\nWe'll also need the karate-junit4 dependency to facilitate JUnit testing:\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.intuit.karate\u003c/groupId\u003e\n    \u003cartifactId\u003ekarate-junit4\u003c/artifactId\u003e\n    \u003cversion\u003e0.6.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n## Creating Tests\nWe'll start by writing tests for some common scenarios in a Gherkin Feature file.\n### Testing the Status Code\nLet's write a scenario that tests a GET endpoint and checks if it returns a 200 (OK) HTTP status code:\n```\nScenario: Testing valid GET endpoint\nGiven url 'http://localhost:8097/user/get'\nWhen method GET\nThen status 200\n```\nThis works obviously with all possible HTTP status codes.\n### Testing the Response\nLet's a write another scenario that tests that the REST endpoint returns a specific response:\n\n```\nScenario: Testing the exact response of a GET endpoint\nGiven url 'http://localhost:8097/user/get'\nWhen method GET\nThen status 200\nAnd match $ == {id:\"1234\",name:\"John Smith\"}\n```\nThe match operation is used for the validation where ‘$' represents the response. So the above scenario checks that the response exactly matches ‘{id:”1234″,name:”John Smith”}'.\nWe can also check specifically for the value of the id field:\nAnd match $.id == \"1234\"\n## Running Tests\nNow that the test scenarios are complete, we can run our tests by integrating Karate with JUnit.\n```\n@RunWith(Karate.class)\n@CucumberOptions(features = \"classpath:karate\")\npublic class KarateUnitTest {\n//...     \n}\n```\nNote: We can also karate-config.js file to store global variables,configure execution environment,baseurl,timeout time.\nKarate read this file before executing any scenario.\nTo use karate env in testrunner class:\n@BeforeClass\npublic static void Before()\n{   System.setProperty(\"karate.env\",\"qa\")\n}\n\n\nThank You\\\nHappy Coding,\\\nLearn,Code and Earn\\\nStay Safe and Stay Positive :)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanshul-sonpure%2Fkarate_tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanshul-sonpure%2Fkarate_tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanshul-sonpure%2Fkarate_tutorial/lists"}