-
Notifications
You must be signed in to change notification settings - Fork 21
Assignment 1 and Assignment 3 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| @prod | ||
| Feature: Get user details | ||
| Background: | ||
| * def userid = 1 | ||
|
|
||
| @jsonPlaceHolder | ||
| Scenario: Fetch all the posts | ||
| * def userResponse = karate.call('classpath:com/znsio/templates/fetchingUserDetailsJsonPlaceHolder.feature@t_getPost', {userId:userid}).listOfPosts | ||
| * print userResponse | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use karate.log() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ?? |
||
| * match userResponse.id == userid | ||
| * match userResponse.id == '#number' | ||
| * match userResponse.title == '#string' | ||
| * match userResponse.body == '#string' | ||
|
|
||
| @jsonPlaceHolder | ||
| Scenario: Fetch all the comments | ||
| * def userResponse = karate.call('classpath:com/znsio/templates/fetchingUserDetailsJsonPlaceHolder.feature@t_getComment', {userId:userid}).listOfComments | ||
| * print userResponse | ||
| * match userResponse.id == userid | ||
| * match userResponse.id == '#number' | ||
| * match userResponse.name == '#string' | ||
| * match userResponse.email == '#string' | ||
| * match userResponse.body == '#string' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For both Posts and Comments API tests are missing. Try out all valid and invalid scenarios to achieve good test coverage!. |
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| Feature: Fetching user details | ||
|
||
|
|
||
| Background: | ||
| * print "base url "+env.baseUrl | ||
| Given url env.baseUrl | ||
|
|
||
| @t_getPost | ||
| Scenario: Get Posts for particular user id | ||
| Given path "/posts/"+userId | ||
| When method Get | ||
| Then status 200 | ||
| * def listOfPosts = response | ||
|
|
||
| @t_getComment | ||
| Scenario: Get Comments for particular user id | ||
| Given path "/comments/"+userId | ||
| When method Get | ||
| Then status 200 | ||
| * def listOfComments = response | ||
|
|
||
| @t_getPosts | ||
| Scenario: Get Posts for all the user | ||
| And path '/posts' | ||
| When method Get | ||
| Then status 200 | ||
| * def posts = response | ||
|
|
||
| @t_getComments | ||
| Scenario: Get Comments for all the user | ||
| And path '/comments' | ||
| When method Get | ||
| Then status 200 | ||
| * def comments = response | ||
|
|
||
| @t_CreatePost | ||
| Scenario: Create new post | ||
| And path '/posts' | ||
| And request {"title": '#(title)',"body": '#(body)',"userId": '#(userId)'} | ||
| When method Post | ||
| Then status 201 | ||
| * def post = response | ||
|
|
||
| @t_EditPost | ||
| Scenario: Edit already created post | ||
| And path '/posts/'+id | ||
| And request input | ||
| When method Patch | ||
| Then status 200 | ||
| * def edit = response | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "title": "Practice1", | ||
| "body": "BYE" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| @prod | ||
| Feature: Edit the post | ||
|
|
||
| @createPost | ||
| Scenario Outline: Edit the post by creating it | ||
| Given json postedDetails = karate.call('classpath:com/znsio/templates/fetchingUserDetailsJsonPlaceHolder.feature@t_CreatePost', {title:'<title>',body:'<body>',userId:'<userId>'}).post | ||
| * print postedDetails | ||
| * match postedDetails.title == '<title>' | ||
| * match postedDetails.body == '<body>' | ||
| * match postedDetails.userId == '<userId>' | ||
| * def id = postedDetails.userId | ||
| * print "generated id is ", id | ||
|
|
||
| * def input = read('classpath:com/znsio/userDetails.json'); | ||
| Given json editedDetails = karate.call('classpath:com/znsio/templates/fetchingUserDetailsJsonPlaceHolder.feature@t_EditPost', {input : input,id : id}).edit | ||
| * print editedDetails | ||
| * match editedDetails.title == input.title | ||
| * match editedDetails.body == input.body | ||
| * match editedDetails.title == '#string' | ||
| * match editedDetails.body == '#string' | ||
|
|
||
| Examples: | ||
| | title |body|userId| | ||
| | Practice| hello | 50| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userResponse name is incorrect. Its not reflecting what it contains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??