Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #406 from leider/master

FitNesseSuite retrieves FitnesseDir also via system property
  • Loading branch information...
commit 4045fd499e1cbbfd796b0fe7ce91ff87f400edc0 2 parents 4565239 + 7cc688d
@amolenaar amolenaar authored
View
35 src/fitnesse/junit/FitNesseSuite.java
@@ -77,23 +77,33 @@
}
/**
* The <code>FitnesseDir</code> annotation specifies the absolute or relative
- * path to the directory in which FitNesseRoot can be found
+ * path to the directory in which FitNesseRoot can be found. You can either specify
+ * <ul>
+ * <li>a relative or absolute path directly, e.g.: <code>@FitnesseDir("/parentOfFitNesseRoot")</code>,
+ * or you can specify
+ * <li>a system property the content of which will be taken as base dir and
+ * optionally give a path extension, e.g.:
+ * <code>@FitnesseDir(systemProperty = "fitnesse.root.dir.parent")</code></li>
+ * </ul>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface FitnesseDir {
- public String value();
+ public String value() default "";
+ public String systemProperty() default "";
public String fitNesseRoot() default "FitNesseRoot";
}
/**
* The <code>OutputDir</code> annotation specifies where the html reports of
- * run suites and tests will be found after running them. You can either
- * specify a relative or absolute path directly, e.g.: <code>@OutputDir("/tmp/trinidad-results")</code>, or you can
- * specify a
- * system property the content of which will be taken as base dir and
+ * run suites and tests will be found after running them. You can either specify
+ * <ul>
+ * <li>a relative or absolute path directly, e.g.: <code>@OutputDir("/tmp/trinidad-results")</code>,
+ * or you can specify
+ * <li>a system property the content of which will be taken as base dir and
* optionally give a path extension, e.g.:
- * <code>@OutputDir(systemProperty = "java.io.tmpdir", pathExtension = "trinidad-results")</code>
+ * <code>@OutputDir(systemProperty = "java.io.tmpdir", pathExtension = "trinidad-results")</code></li>
+ * </ul>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@@ -170,7 +180,16 @@ static String getFitnesseDir(Class<?> klass)
if (fitnesseDirAnnotation == null) {
throw new InitializationError("There must be a @FitnesseDir annotation");
}
- return fitnesseDirAnnotation.value();
+ if (!"".equals(fitnesseDirAnnotation.value())) {
+ return fitnesseDirAnnotation.value();
+ }
+ if (!"".equals(fitnesseDirAnnotation.systemProperty())) {
+ String baseDir = System.getProperty(fitnesseDirAnnotation.systemProperty());
+ File outputDir = new File(baseDir);
+ return outputDir.getAbsolutePath();
+ }
+ throw new InitializationError(
+ "In annotation @FitnesseDir you have to specify either 'value' or 'systemProperty'");
}
public static String getFitNesseRoot(Class<?> klass) {
View
6 test/fitnesse/junit/FitNesseSuiteArgumentsTest.java
@@ -10,10 +10,12 @@
@Test
public void argumentsAreParsedCorrectly() throws InitializationError{
+ System.setProperty("fitnesse.root.dir.parent", ".");
assertEquals(".", FitNesseSuite.getFitnesseDir(FitNesseSuiteExampleTest.class));
+ assertEquals(new File(System.getProperty("fitnesse.root.dir.parent")).getAbsolutePath(), FitNesseSuite.getFitnesseDir(FitNesseSuiteExampleFromPropertiesTest.class));
assertEquals("FitNesse.SuiteAcceptanceTests.SuiteSlimTests", FitNesseSuite.getSuiteName(FitNesseSuiteExampleTest.class));
- assertEquals("FitNesse.SuiteAcceptanceTests.SuiteSlimTests", FitNesseSuite.getSuiteName(FitNesseSuiteExampleTest.class));
- assertEquals(new File(System.getProperty("java.io.tmpdir"),"fitnesse").getAbsolutePath(),FitNesseSuite.getOutputDir(FitNesseSuiteExampleTest.class));
+ assertEquals("tmp",FitNesseSuite.getOutputDir(FitNesseSuiteExampleTest.class));
+ assertEquals(new File(System.getProperty("java.io.tmpdir"),"fitnesse").getAbsolutePath(),FitNesseSuite.getOutputDir(FitNesseSuiteExampleFromPropertiesTest.class));
assertNull("null filter allowed", FitNesseSuite.getSuiteFilter(FitNesseSuiteExampleTest.class));
assertNull("null exclude filter allowed", FitNesseSuite.getExcludeSuiteFilter(FitNesseSuiteExampleTest.class));
assertEquals("testSuite", FitNesseSuite.getSuiteFilter(FitNesseSuiteWithFilterExampleTest.class));
View
23 test/fitnesse/junit/FitNesseSuiteExampleFromPropertiesTest.java
@@ -0,0 +1,23 @@
+package fitnesse.junit;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import fitnesse.junit.FitNesseSuite.FitnesseDir;
+import fitnesse.junit.FitNesseSuite.Name;
+import fitnesse.junit.FitNesseSuite.OutputDir;
+import fitnesse.junit.FitNesseSuite.ConfigFile;
+
+
+@RunWith(FitNesseSuite.class)
+@Name("FitNesse.SuiteAcceptanceTests.SuiteSlimTests")
+@FitnesseDir(systemProperty = "fitnesse.root.dir.parent")
+@OutputDir(systemProperty = "java.io.tmpdir", pathExtension = "fitnesse")
+@ConfigFile("plugins.properties")
+public class FitNesseSuiteExampleFromPropertiesTest {
+
+ @Test
+ public void dummy(){
+
+ }
+}
View
2  test/fitnesse/junit/FitNesseSuiteExampleTest.java
@@ -12,7 +12,7 @@
@RunWith(FitNesseSuite.class)
@Name("FitNesse.SuiteAcceptanceTests.SuiteSlimTests")
@FitnesseDir(".")
-@OutputDir(systemProperty = "java.io.tmpdir", pathExtension = "fitnesse")
+@OutputDir("tmp")
@ConfigFile("plugins.properties")
public class FitNesseSuiteExampleTest {
Please sign in to comment.
Something went wrong with that request. Please try again.