forked from fmueller/sonar-scala
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace deprecated functions and add test for SurefireUtils class
- Loading branch information
Showing
10 changed files
with
146 additions
and
35 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
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
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
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
71 changes: 71 additions & 0 deletions
71
src/test/java/org/sonar/plugins/scala/surefire/SurefireUtilsTest.java
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Sonar Scala Plugin | ||
* Copyright (C) 2011 - 2014 All contributors | ||
* [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 | ||
*/ | ||
package org.sonar.plugins.scala.surefire; | ||
|
||
import static org.fest.assertions.Assertions.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.io.File; | ||
|
||
import org.apache.maven.project.MavenProject; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.sonar.api.batch.fs.internal.DefaultFileSystem; | ||
import org.sonar.api.config.Settings; | ||
import org.sonar.api.test.MavenTestUtils; | ||
|
||
public class SurefireUtilsTest { | ||
|
||
private DefaultFileSystem fileSystem; | ||
private Settings settings; | ||
|
||
@Before | ||
public void setUp() { | ||
this.fileSystem = new DefaultFileSystem(); | ||
this.settings = mock(Settings.class); | ||
} | ||
|
||
@Test | ||
public void shouldGetReportsFromProperty() { | ||
fileSystem.setBaseDir(new File("src/test/resources/surefire")); | ||
when(settings.getString("sonar.junit.reportsPath")).thenReturn("targetdir/surefire-reports"); | ||
assertThat(SurefireUtils.getReportsDirectory(fileSystem, settings, null).exists()).isTrue(); | ||
assertThat(SurefireUtils.getReportsDirectory(fileSystem, settings, null).isDirectory()).isTrue(); | ||
} | ||
|
||
@Test | ||
public void shouldGetReportsFromPluginConfiguration() { | ||
MavenProject pom = MavenTestUtils.loadPom(getClass(), "shouldGetReportsFromPluginConfiguration/pom.xml"); | ||
assertThat(SurefireUtils.getReportsDirectory(fileSystem, settings, pom).exists()).isTrue(); | ||
assertThat(SurefireUtils.getReportsDirectory(fileSystem, settings, pom).isDirectory()).isTrue(); | ||
} | ||
|
||
@Test | ||
public void shouldGetReportsFromDefaultConfiguration() { | ||
fileSystem.setBaseDir(new File("src/test/resources/surefire")); | ||
File reportsDir = SurefireUtils.getReportsDirectory(fileSystem, settings, null); | ||
assertThat(reportsDir.getPath().endsWith("src/test/resources/surefire/target/surefire-reports")).isTrue(); | ||
assertThat(reportsDir.getPath().endsWith("src/test/resources/surefire/target/foo")).isFalse(); | ||
} | ||
|
||
|
||
|
||
} |
21 changes: 21 additions & 0 deletions
21
.../plugins/scala/surefire/SurefireUtilsTest/shouldGetReportsFromPluginConfiguration/pom.xml
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<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>fake.group</groupId> | ||
<artifactId>fake.artifactId</artifactId> | ||
<packaging>jar</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.4</version> | ||
<configuration> | ||
<reportsDirectory>src/test/resources/surefire/targetdir/test-reports</reportsDirectory> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Empty file.
Empty file.
Empty file.
Empty file.