I run BDD behave features tests for multiple units under test . so same feature runs multiple times , and I update the behave.ini to save the generated reports in different folders . My problem is when displaying the reports in Jenkins they all have the same name ,TEST_,so it is hard to tell which report is for which unit . Is there a way I can display the reports in jenkins under folder structure ? or change the name of the reports to add the unit name running ?
This is my .ini file
[behave]
default_tags = -@xfail -@wip
default_format = pretty
show_skipped = false
show_timings = true
stdout_capture = no
logging_level = ERROR
format = rerun
progress3
pretty
outputs = rerun.txt
test_reports/progress3_report.txt
junit = true
junit_directory = test_reports/
And this is how I display the reports in jenkinsfile
stage('Run Tests')
{
steps {
stash includes: "**/*", name: "workspace"
node("rpi") {
script{
unstash "workspace"
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh """
rm -rf test_reports
python -m venv venv && . venv/bin/activate
venv/bin/pip install --upgrade pip wheel
venv/bin/pip install --upgrade -r BDD/requirements.txt
python runner.py $units
"""
}
}
junit 'test_reports/**/*.xml'
}
}
}
in runner.py I update the junit_directory to add the units folder
I am looking to display reports in this format
TEST_F1_UNIT_1
TEST_F1_UNIT_2
TEST_F1_UNIT_3
TEST_F2_UNIT_1
TEST_F2_UNIT_2
TEST_F2_UNIT_3
Instead I get
TEST_F1
TEST_F1
TEST_F1
TEST_F2
TEST_F2
TEST_F2
In case someone is having the same problem . Turns out there is an easy way by just renaming the features and scenarios to include the unit name in the before hook functions .
In enviroment.py
def before_feature(context, feature):
feature.name = feature.name + '_' + context.unit.name
def before_scenario(context, feature):
feature.name = scenario.name + '_' + context.unit.name
This way the feature reports will include the unit names and be readable from jenkins