Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,25 @@ String getReportSourceName() {
}

String getReportSourceName(String suffix) {
return isBlank(suffix) ? getReportSourceName() : getReportSourceName() + "(" + suffix + ")";
return withReportNameSuffix(getReportSourceName(), suffix);
}

String getSourceName(String suffix) {
return isBlank(suffix) ? getSourceName() : getSourceName() + "(" + suffix + ")";
return withReportNameSuffix(getSourceName(), suffix);
}

String getSourceQualifiedName(String suffix) {
String qualifiedName = original.getSourceQualifiedName();
if (qualifiedName != null) {
return isBlank(suffix) ? qualifiedName : qualifiedName + "(" + suffix + ")";
return withReportNameSuffix(qualifiedName, suffix);
}
// Fall back to pre-existing behaviour: sourceText if set, else sourceName (with suffix)
// Fall back to the same source selected before qualified names were tracked.
String sourceText = getSourceText();
return sourceText != null ? sourceText : getSourceName(suffix);
return sourceText != null ? withReportNameSuffix(sourceText, suffix) : getSourceName(suffix);
}

private static String withReportNameSuffix(String sourceName, String suffix) {
return isBlank(suffix) ? sourceName : sourceName + "(" + suffix + ")";
}

String getReportName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ public void testRegular() {
assertEquals("surefire.testcase.JunitParamsTest", wr.getNameWithGroup());
}

@Test
public void sourceQualifiedNameFallsBackToSourceTextWithSuffix() {
ReportEntry reportEntry = new SimpleReportEntry(
NORMAL_RUN, 1L, "JunitParamsTest", "surefire.testcase.JunitParamsTest", "testSum", null);
WrappedReportEntry wr = new WrappedReportEntry(reportEntry, null, 1771085631L, 12, null, null);
assertEquals("surefire.testcase.JunitParamsTest(BDD)", wr.getSourceQualifiedName("BDD"));
}

@Test
public void testDisplayNames() {
ReportEntry reportEntry = new SimpleReportEntry(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
package org.apache.maven.surefire.its.jiras;

import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.TestFile;
import org.junit.jupiter.api.Test;

public class Surefire3210ReportNameSuffixIT extends SurefireJUnit4IntegrationTestCase {
@Test
public void reportNameSuffixIsUsedInTestcaseClassname() {
OutputValidator validator =
unpack("surefire-3210-report-name-suffix").executeTest().verifyErrorFree(1);

TestFile reportFile = validator.getSurefireReportsXmlFile("TEST-jira3210.MonkeyTest-Linux.xml");
reportFile
.assertContainsText("name=\"jira3210.MonkeyTest(Linux)\"")
.assertContainsText("<testcase name=\"testMonkeyConvert\" classname=\"jira3210.MonkeyTest(Linux)\"");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you 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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.plugins.surefire</groupId>
<artifactId>surefire-3210-report-name-suffix</artifactId>
<version>1.0</version>
<name>Test for SUREFIRE-3210: reportNameSuffix in XML report classname</name>

<properties>
<junit5.version>5.13.4</junit5.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<configuration>
<reportNameSuffix>Linux</reportNameSuffix>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
package jira3210;

import org.junit.jupiter.api.Test;

class MonkeyTest {
@Test
void testMonkeyConvert() {}
}
Loading