Skip to content

Writing JUnit XML fails when skipping a scenario #769

@HorizonNet

Description

@HorizonNet

Description

After the recent update of the radish-bdd dependency writing a JUnit XML file fails when a scenario gets skipped. The error itself seems to come from radish.

The same feature file completed without an error in v1.3.50.

To Reproduce

Feature File:

Scenario: Ensure all resources have tags
  Given I have resource that supports tags defined
  Given I have not azapi_resource defined
  Then it must contain tags
  And its value must not be null

Sample Terraform Code:

Have a Terraform configuration without an azapi_resource defined

resource "aws_s3_bucket" "example_code" {
   bucket = "This is just a sample code"
}

Used terraform-compliance Parameters:

terraform-compliance -p plan.json -f tests/ --junit-xml junit.xml

Error Output:

! ERROR: Hook 'generate_junit_xml' from /home/vsts/.local/lib/python3.12/site-packages/radish/extensions/junit_xml_writer.py:80 raised: 'UnboundLocalError: cannot access local variable 'testcase_element' where it is not associated with a value'

Traceback (most recent call last):
  File "/home/vsts/.local/lib/python3.12/site-packages/radish/hookregistry.py", line 133, in call
    func(model, *args, **kwargs)
  File "/home/vsts/.local/lib/python3.12/site-packages/radish/extensions/junit_xml_writer.py", line 161, in generate_junit_xml
    testcase_element.append(skipped_element)
    ^^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'testcase_element' where it is not associated with a value

Expected Behavior:

terraform-compliance should write a JUnit XML file.

Tested Versions:

  • terraform-compliance version: 1.3.52
  • terraform version: 1.11.4
  • python version: 3.12.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions