# Can I run Setup, Test and Teardown separately?

**URL:** <https://forum.robotframework.org/t/can-i-run-setup-test-and-teardown-separately/3878>\
**Category:** Python\
**Created:** [25 May 2022 10:27 UTC](https://forum.robotframework.org/t/can-i-run-setup-test-and-teardown-separately/3878 "2022-05-25T10:27:50Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [6 March 2023 01:46 UTC](https://forum.robotframework.org/t/can-i-run-setup-test-and-teardown-separately/3878/14 "2023-03-06T01:46:22Z")

</div>

I was revisiting this and decided to post a full working example incase it helps someone else.

BTW Thanks @pekkaklarck for all your help with this.

# Run Command:

```python
robot --listener TestRepeater.py repeatme.robot

```

# TestRepeater.py

```python
from robot.api import SuiteVisitor
import time

class TestRepeater(SuiteVisitor):
	ROBOT_LISTENER_API_VERSION = 3

	testname = None
	count = 1

	def end_test(self, test, result):
		# print("test:", test)
		# print("test.parent:", test.parent)
		# print("test.parent.tests:", test.parent.tests)

		if self.count < 5:
			self.count += 1
			if self.testname is None:
				self.testname = test.name
			newname = "{} {}".format(self.testname, self.count)
			copy = test.copy(name=newname)
			test.parent.tests.append(copy)
			# test.parent.tests.append(test)

	def end_suite(self, suite, result):
		# This prevents the error:
		# [ERROR] Calling method 'end_suite' of listener 'TestRepeater.py' failed: TypeError: end_suite() takes 2 positional arguments but 3 were given
		pass

	def start_suite(self, suite, result):
		# This prevents the error:
		# [ERROR] Calling method 'start_suite' of listener 'TestRepeater.py' failed: TypeError: start_suite() takes 2 positional arguments but 3 were given
		pass

	def start_test(self, test, result):
		# This prevents the error:
		# [ERROR] Calling method 'start_test' of listener 'TestRepeater.py' failed: TypeError: start_test() takes 2 positional arguments but 3 were given
		pass

```

# repeatme.robot

```python
***Settings***
Suite Setup SS keyword
Suite Teardown ST keyword
Test Setup TS keyword
Test Teardown TT keyword

***Test Cases***
Repeat Me
	${time} =	Get Time
	Log Repeat Me ${time}
	Log To Console Repeat Me ${time}
	Sleep 5

***Keywords***

SS keyword
	Log Suite Setup
	Log To Console Suite Setup

TS keyword
	Log Test Setup
	Log To Console Test Setup

ST keyword
	Log Suite Teardown
	Log To Console Suite Teardown

TT keyword
	Log Test Teardown
	Log To Console Test Teardown

```

# Result

 ![Screenshot 2023-03-06 at 11.45.44 am](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/a/afcd447dddeec1ca02ca44e094825f8be13c5d7a.png)

```python
==============================================================================
Repeatme                                                                      
==============================================================================
Suite Setup
Repeat Me Test Setup
...Repeat Me 2023-03-06 11:36:24
..Test Teardown
Repeat Me | PASS |
------------------------------------------------------------------------------
Repeat Me 2 Test Setup
...Repeat Me 2023-03-06 11:36:29
..Test Teardown
Repeat Me 2 | PASS |
------------------------------------------------------------------------------
Repeat Me 3 Test Setup
...Repeat Me 2023-03-06 11:36:34
..Test Teardown
Repeat Me 3 | PASS |
------------------------------------------------------------------------------
Repeat Me 4 Test Setup
...Repeat Me 2023-03-06 11:36:39
..Test Teardown
Repeat Me 4 | PASS |
------------------------------------------------------------------------------
Repeat Me 5 Test Setup
...Repeat Me 2023-03-06 11:36:44
..Test Teardown
Repeat Me 5 | PASS |
------------------------------------------------------------------------------
Suite Teardown
Repeatme | PASS |
5 tests, 5 passed, 0 failed
==============================================================================
Output: /Users/dave/tmp/RepeatTest/output.xml
Log: /Users/dave/tmp/RepeatTest/log.html
Report: /Users/dave/tmp/RepeatTest/report.html

```

---

_[View the full topic](https://forum.robotframework.org/t/can-i-run-setup-test-and-teardown-separately/3878)._
