aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-02-05 19:07:42 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2013-02-05 19:10:17 +0100
commitb58601cce773c23cdef9feb56e0cc486f000001a (patch)
tree1acd3da6c4cdaabb0e7375f5613beb3da418e079 /sonar-plugin-api
parentf0e662a2b73e0e9ae70b005e7093c5c27fab24d8 (diff)
downloadsonarqube-b58601cce773c23cdef9feb56e0cc486f000001a.tar.gz
sonarqube-b58601cce773c23cdef9feb56e0cc486f000001a.zip
SONAR-2501 a test plan can have multiple test cases with the same name (see TestNG)
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestCase.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/test/TestCase.java19
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/test/TestPlan.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestCaseAlreadyExistsException.java26
5 files changed, 13 insertions, 40 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestCase.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestCase.java
index ee258383d9f..a65b652750a 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestCase.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestCase.java
@@ -24,12 +24,10 @@ import javax.annotation.Nullable;
import java.util.List;
public interface MutableTestCase extends TestCase {
- MutableTestCase setStatus(String s);
+ MutableTestCase setStatus(Status s);
MutableTestCase setDurationInMs(@Nullable Long l);
- MutableTestCase setName(String s);
-
MutableTestCase setMessage(String s);
MutableTestCase setStackTrace(String s);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/TestCase.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/TestCase.java
index 168b07ad189..5b89bbb7fda 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/test/TestCase.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/test/TestCase.java
@@ -19,22 +19,23 @@
*/
package org.sonar.api.test;
+import javax.annotation.Nullable;
+
public interface TestCase {
- String STATUS_PASS = "pass";
- String STATUS_FAIL = "fail";
+ enum Status {
+ OK, FAILURE, ERROR, SKIPPED;
+
+ public static Status of(@Nullable String s) {
+ return s == null ? null : valueOf(s.toUpperCase());
+ }
+ }
/**
* Duration in milliseconds
*/
Long durationInMs();
- // pass/fail/...
- String status();
-
- /**
- * The key is not null and unique among the test plan.
- */
- String key();
+ Status status();
String name();
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/TestPlan.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/TestPlan.java
index 1c334e2442b..1b1bb914cb9 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/test/TestPlan.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/test/TestPlan.java
@@ -32,5 +32,5 @@ public interface TestPlan<T extends TestCase> extends Perspective {
Iterable<T> testCases();
- T testCaseByKey(String key);
+ Iterable<T> testCasesByName(String name);
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java
index f11a3a5fef8..77ec933b522 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java
@@ -28,7 +28,7 @@ public interface Testable extends Perspective {
List<TestCase> testCases();
- TestCase testCaseByKey(String key);
+ TestCase testCaseByName(String key);
int countTestCasesOfLine(Integer line);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestCaseAlreadyExistsException.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestCaseAlreadyExistsException.java
deleted file mode 100644
index ff1453b9ba8..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestCaseAlreadyExistsException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.test.exception;
-
-public class TestCaseAlreadyExistsException extends TestException {
- public TestCaseAlreadyExistsException(String componentKey, String testCaseKey) {
- super(String.format("Test case already exists for %s: %s", componentKey, testCaseKey));
- }
-}