Skip to content

JUnit testcase name not unique per failure #1608

Open
@markafarrell

Description

@markafarrell

Summary

Problem

When there are multiple linting issues with the same cause, the test case name is not unique.

This causes issues when the JUnit results are parsed (by GitLab) which discards all the failures except the final one.

image

Proposed Solution

Include the file and line number in the testcase name

e.g. <testcase classname="main.tf" name="terraform_deprecated_interpolation main.tf:197,31-75" time="0">

Command

docker run --rm -v $(pwd):/data -t ghcr.io/terraform-linters/tflint:v0.43.0 --format junit

Terraform Configuration

variable "bucket_name" {
  description = "Bucket name"
  type        = string
}
variable "bucket_name1" {
  description = "Bucket name"
  type        = string
}

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 2.7.0"
    }
  }
}

resource "aws_s3_bucket" "example" {
  bucket = "${var.bucket_name}"
}

resource "aws_s3_bucket" "example1" {
  bucket = "${var.bucket_name1}"
}

TFLint Configuration

Default

Output

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite tests="3" failures="3" time="0" name="">
    <properties></properties>
    <testcase classname="" name="terraform_required_version" time="0">
      <failure message=":0,0-0: terraform &#34;required_version&#34; attribute is required" type="Warning">Warning: terraform &#34;required_version&#34; attribute is required&#xA;Rule: terraform_required_version&#xA;Range: :0,0-0</failure>
    </testcase>
    <testcase classname="main.tf" name="terraform_deprecated_interpolation" time="0">
      <failure message="main.tf:20,12-32: Interpolation-only expressions are deprecated in Terraform v0.12.14" type="Warning">Warning: Interpolation-only expressions are deprecated in Terraform v0.12.14&#xA;Rule: terraform_deprecated_interpolation&#xA;Range: main.tf:20,12-32</failure>
    </testcase>
    <testcase classname="main.tf" name="terraform_deprecated_interpolation" time="0">
      <failure message="main.tf:24,12-33: Interpolation-only expressions are deprecated in Terraform v0.12.14" type="Warning">Warning: Interpolation-only expressions are deprecated in Terraform v0.12.14&#xA;Rule: terraform_deprecated_interpolation&#xA;Range: main.tf:24,12-33</failure>
    </testcase>
  </testsuite>

TFLint Version

0.43.0

Terraform Version

No response

Operating System

  • Linux
  • macOS
  • Windows

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions