Setup/Teardown per test case

Best practices, code snippets for common functionality, examples, and guidelines.
armstronghm24
Posts: 38
Joined: Tue Dec 20, 2016 10:16 pm

Setup/Teardown per test case

Post by armstronghm24 » Tue Oct 30, 2018 7:51 pm

Hi,

I would like to perform a setup/teardown in a test case where the setup runs at the beginning, a number of the same test cases are run and then the teardown is run at the end. This works when the setup/teardown is at the test suite level, but it doesn't work correctly at the test case level. Why even provide the option of setup/teardown at the test case level if it repeats itself at each iteration of the test case anyway? Hopefully someone understands what I am getting at. Otherwise I can explain in further detail.

User avatar
Vega
Posts: 109
Joined: Mon Jul 11, 2016 2:15 pm

Re: Setup/Teardown per test case

Post by Vega » Tue Oct 30, 2018 8:04 pm

What does your current test suite structure look like? Have you tried using smart folders within your test case(s)? It sounds like you are using either data binding or the iteration counter on your test case. Perhaps making a smart folder within the test case container and then applying the data binding / iteration counter to the smart folder could work for you. Perhaps something like this:

[TestCase]
--[Setup]
----[Smart Folder] *contains data binding / iteration counter
------[test modules] (these modules would be iterated over)
--[Teardown]

If this is not quite what you are looking for, it would be helpful if you are able to provide a screenshot of your test suite or at least an example.

armstronghm24
Posts: 38
Joined: Tue Dec 20, 2016 10:16 pm

Re: Setup/Teardown per test case

Post by armstronghm24 » Fri Nov 09, 2018 5:19 pm

I could use smart folders, but I would rather not as it is less organized from my perspective. I want something like this:
Test Suite
Test Suite Setup
- Testcase1
- Setup
- test case modules test case 1 (multiple iterations)
- Testcase2
- Setup
- Test case modules test case 2 (multiple iterations)

What is the purpose of the setup if it runs every time during a test case? Why not just make it a test case module? I want the setup to run once and then run through the test case modules multiple times in a test case.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Setup/Teardown per test case

Post by odklizec » Mon Nov 12, 2018 9:38 am

Hi,

In my opinion, the Setup/Teardown implementation, as it is now, is perfectly logical. But of course, it may not suit everybody ;) The thing is, that both Setup and Teardown are a part of iteration! In other words, the iteration starts once the test reaches the test case/smart folder, containing a data connector. Once the test enters the test case/smart folder, it goes into iteration 1 and so its setup/teardown section. Vega provided you with a perfectly working solution of the problem and it's exactly what I would do in case like yours. This is exactly what smart folders are for ;) If you don't like the current implementation of Setup/Teardown, you can always suggest a change via Ranorex User Voice platform, available here:
https://uservoice.ranorex.com/forums/15 ... ve-ranorex
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

armstronghm24
Posts: 38
Joined: Tue Dec 20, 2016 10:16 pm

Re: Setup/Teardown per test case

Post by armstronghm24 » Tue Nov 13, 2018 10:11 pm

I get your point. Thanks for the assistance.