-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Docstrings and updated README.md.
- Loading branch information
Showing
2 changed files
with
104 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,39 @@ | ||
# robotframework-testrepeater | ||
A listener to repeat testscases for given iterations. | ||
# Robot Framework Test Repeater | ||
|
||
**Test Repeater** is a listener plugin for Robot Framework that allows you to repeat each test case in a suite a specified number of times. | ||
This can be useful for scenarios where you want to execute the same test cases multiple times with different inputs or configurations. | ||
|
||
## Installation | ||
|
||
Ensure you have Python and Robot Framework installed. | ||
|
||
``` | ||
pip install robotframework-testrepeater | ||
``` | ||
|
||
## Usage | ||
|
||
You can use Test Repeater by specifying it as a listener when running your Robot Framework tests. Here's how you can do it: | ||
|
||
``` | ||
robot --listener TestRepeater:<count> <test-suite> | ||
``` | ||
|
||
Replace `<count>` with the number of times you want each test case to be repeated, and `<test-suite>` with the path to your Robot Framework test suite. | ||
|
||
For example: | ||
|
||
``` | ||
robot --listener TestRepeater:2 example/example.robot | ||
``` | ||
|
||
This command will repeat each test case in `example/example.robot` 2 times. | ||
|
||
|
||
## License | ||
|
||
Test Repeater is licensed under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for details. | ||
|
||
## Author | ||
|
||
Test Repeater is maintained by reharish and abi-sheak. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,91 @@ | ||
# pylint: disable=C0103 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
""" | ||
Author: reharish, abi-sheak | ||
Requirements: robotframework | ||
""" | ||
|
||
from robot.api import SuiteVisitor | ||
|
||
class TestRepeater(SuiteVisitor): | ||
""" | ||
TestRepeater is a Robot Framework Listener that repeats each test case in a suite a specified number of times. | ||
This listener is intended to be used as a listener plugin with Robot Framework. | ||
count (int): The number of times each test case should be repeated. | ||
Example: | ||
robot --listener TestRepeater:<count> <test-suite> | ||
robot --listener TestRepeater:2 example/example.robot | ||
""" | ||
|
||
ROBOT_LISTENER_API_VERSION = 3 | ||
|
||
def __init__(self, count): | ||
""" | ||
Initialize TestRepeater with the given repetition count. | ||
count (int): The number of times each test case should be repeated. | ||
""" | ||
self.count = int(count) | ||
|
||
def start_suite(self, suite, result): | ||
""" | ||
Called when a suite starts. | ||
Creates a tests list as from the count. | ||
Repeats each test case in the suite. | ||
""" | ||
testcases = [] | ||
for iter in range(1, self.count+1): | ||
for iteration in range(1, self.count + 1): | ||
for test in suite.tests: | ||
copy = test.copy(name=f"{iter} - {test.name}") | ||
copy = test.copy(name=f"{iteration} - {test.name}") | ||
testcases.append(copy) | ||
suite.tests = testcases | ||
|
||
def end_suite(self, suite, result): | ||
""" | ||
Called when a suite ends. | ||
""" | ||
pass | ||
|
||
def start_test(self, test, result): | ||
""" | ||
Called when a test starts. | ||
""" | ||
pass | ||
|
||
def end_test(self, test, result): | ||
""" | ||
Called when a test ends. | ||
""" | ||
pass | ||
|
||
def start_keyword(self,test, result): | ||
def start_keyword(self, keyword, result): | ||
""" | ||
Called when a keyword starts. | ||
""" | ||
pass | ||
|
||
def end_keyword(self,test, result): | ||
def end_keyword(self, keyword, result): | ||
""" | ||
Called when a keyword ends. | ||
""" | ||
pass |