-1

I am writing the test suite for my endpoints.I am having one problem which is for running the 1 test suite twice. For Example, When I add an image with endpoints it adds the Image with a unique Id and returns successfully. This unique Id is generated new every time. So we have another endpoint where we pass unique IDs to delete. So it is successful for the first time but when we run the delete second time the same query then that id is deleted and it says it does not exists. how do we automate this thing? I mean the test case should not fail.

I tried to search but could not able to find any resource, Any help will be appreciated. Thanks.

user2911592
  • 91
  • 12
  • Could you please be a bit more specific. What are you trying to achieve the second time you call the delete endpoint? That you cannot delete an already deleted image or ...? – TestPete Jan 04 '21 at 12:40
  • Yes, we cannot delete the deleted image. For more clarification, we have two test suites for the delete endpoint.The first is with a valid unique Id and the second test suite is for does not exist. So, If I run these 2 test suites the first time both test cases will be pass. but suppose if I will run these on sum automated system which will run these test cases so many times then 1 will pass and 1 is fail always after the second run because its already deleted. So is there any way so that we can always run these 2 test cases and they pass.I hope I am clear now – user2911592 Jan 04 '21 at 13:12

1 Answers1

0

Not sure I understand why you have made two test suites for the delete endpoint. Nevertheless, a simple solution would be:

#1 Use a single test suite here.

#2 Create one test case, e.g. "Cannot delete an already deleted image". Here you implicitly tests the deletion of an image using the unique ID.

#3 The test case will have 3 requests:

  • Create image

  • Delete image using unique ID

  • Delete image re-using unique ID.

#4 You use Property Transfer between the requests to share the unique ID

This way you will never encounter the problem raised, and you will be testing both the deletion and the attempt to delete the already deleted image.

If for some reason the tests need to be independent of each other, the above solution needs a bit of tweaking :)

TestPete
  • 106
  • 5