]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2501 Do notAdd unit test
authorJulien Lancelot <julien.lancelot@gmail.com>
Wed, 16 Jan 2013 09:27:22 +0000 (10:27 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Wed, 16 Jan 2013 09:27:22 +0000 (10:27 +0100)
sonar-plugin-api/src/main/java/org/sonar/api/tests/FileTest.java
sonar-plugin-api/src/main/java/org/sonar/api/tests/Test.java
sonar-plugin-api/src/test/java/org/sonar/api/tests/ProjectTestsImplTest.java

index 1d31426600cabdbe8b65324bc19128b104ae5ddd..223a7bc380764ded3691c6d4cba56ca782900a83 100644 (file)
@@ -50,29 +50,6 @@ public class FileTest {
     tests.add(test);
   }
 
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) {
-      return true;
-    }
-    if (o == null || getClass() != o.getClass()) {
-      return false;
-    }
-
-    FileTest fileTest = (FileTest) o;
-
-    if (!key.equals(fileTest.key)) {
-      return false;
-    }
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    return key.hashCode();
-  }
-
   @Override
   public String toString() {
     return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
index 513bc2f65785ca140b98055dafa6f32e6d69ae3c..4ccdf23ca3cea0af3a0e098cbdd66205bf2f9ad6 100644 (file)
@@ -71,29 +71,6 @@ public class Test {
     return this;
   }
 
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) {
-      return true;
-    }
-    if (o == null || getClass() != o.getClass()) {
-      return false;
-    }
-
-    Test test = (Test) o;
-
-    if (!name.equals(test.name)) {
-      return false;
-    }
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    return name.hashCode();
-  }
-
   @Override
   public String toString() {
     return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
index dc0585c4f0c2c75097744b0fdf4e2f4186313819..19c6287a6ecc7b9fee6c3f2852db3e94c3ecf793 100644 (file)
@@ -23,6 +23,7 @@ package org.sonar.api.tests;
 import org.junit.Before;
 import org.junit.Test;
 
+import static com.google.common.collect.Lists.newArrayList;
 import static org.fest.assertions.Assertions.assertThat;
 
 public class ProjectTestsImplTest {
@@ -36,7 +37,12 @@ public class ProjectTestsImplTest {
 
   @Test
   public void should_add_new_test() throws Exception {
-    org.sonar.api.tests.Test test = new org.sonar.api.tests.Test("test").setStatus("ok");
+    org.sonar.api.tests.Test test = new org.sonar.api.tests.Test("test")
+        .setStatus("ok")
+        .setMessage("message")
+        .setStackTrace("stacktrace")
+        .setDurationMilliseconds(10)
+    ;
     projectTests.addTest("key", test);
     assertThat(projectTests.getFileTests()).hasSize(1);
     assertThat(projectTests.getFileTests().get(0).getTests()).hasSize(1);
@@ -53,4 +59,12 @@ public class ProjectTestsImplTest {
     assertThat(projectTests.getFileTests()).hasSize(1);
     assertThat(projectTests.getFileTests().get(0).getTests()).hasSize(2);
   }
+
+  @Test
+  public void should_add_coverage_info() throws Exception {
+    org.sonar.api.tests.Test test = new org.sonar.api.tests.Test("test").setStatus("ok");
+    projectTests.addTest("key", test);
+
+    projectTests.cover("key", "test", "mainFile", newArrayList(1, 2));
+  }
 }