diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-04-21 01:37:08 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-04-21 01:40:19 +0400 |
commit | 986b9dfe5b578402b3ecdb7ccde5abc5fe06f7da (patch) | |
tree | 3d178a356adf1a6cced0ec80fa819f957cab4a6c /plugins | |
parent | 9b4abb9191c24ea7f36b274bd71da3ca0934f189 (diff) | |
download | sonarqube-986b9dfe5b578402b3ecdb7ccde5abc5fe06f7da.tar.gz sonarqube-986b9dfe5b578402b3ecdb7ccde5abc5fe06f7da.zip |
Increase coverage for a new code in UnitTestDecorator
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UnitTestDecoratorTest.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UnitTestDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UnitTestDecoratorTest.java index da3823d9a6d..6caa66a8c69 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UnitTestDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UnitTestDecoratorTest.java @@ -22,6 +22,7 @@ package org.sonar.plugins.core.sensors; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -29,15 +30,18 @@ import org.junit.Before; import org.junit.Test; import org.sonar.api.batch.DecoratorContext; import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.resources.JavaPackage; import org.sonar.api.resources.Project; public class UnitTestDecoratorTest { private UnitTestDecorator decorator; + private DecoratorContext context; @Before public void setUp() { decorator = new UnitTestDecorator(); + context = mock(DecoratorContext.class); } @Test @@ -60,13 +64,24 @@ public class UnitTestDecoratorTest { */ @Test public void shouldSaveZeroOnProject() { - DecoratorContext context = mock(DecoratorContext.class); - Project project = new Project(""); - project.setAnalysisType(Project.AnalysisType.DYNAMIC); + Project project = new Project("").setAnalysisType(Project.AnalysisType.DYNAMIC); decorator.decorate(project, context); verify(context).saveMeasure(CoreMetrics.TESTS, 0.0); } + /** + * See http://jira.codehaus.org/browse/SONAR-2371 + */ + @Test + public void shouldNotSaveZeroOnPackage() { + JavaPackage pkg = new JavaPackage(); + + decorator.decorate(pkg, context); + + assertThat(decorator.shouldDecorateResource(pkg), is(true)); + verify(context, never()).saveMeasure(CoreMetrics.TESTS, 0.0); + } + } |