-
Notifications
You must be signed in to change notification settings - Fork 715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/1152 #1153
Open
micw
wants to merge
2
commits into
unclebob:master
Choose a base branch
from
micw:feature/1152
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/1152 #1153
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package fitnesse.junit; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Provide custom variables to override page variables in a similar way as done with URL-Parameters | ||
* when using the fitnesse-stabdalone runner | ||
* @author mwyraz | ||
*/ | ||
public interface CustomVariableProvider { | ||
public Map<String,String> getCustomVariables(); | ||
} |
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 | ||||
---|---|---|---|---|---|---|
|
@@ -10,6 +10,7 @@ | |||||
import java.util.ArrayList; | ||||||
import java.util.Collections; | ||||||
import java.util.List; | ||||||
import java.util.Map; | ||||||
|
||||||
import fitnesse.ConfigurationParameter; | ||||||
import fitnesse.ContextConfigurator; | ||||||
|
@@ -68,6 +69,16 @@ public class FitNesseRunner extends ParentRunner<WikiPage> { | |||||
boolean value() default true; | ||||||
} | ||||||
|
||||||
/** | ||||||
* The <code>CustomVariableProviderClass</code> annotation specifies an optional {@link CustomVariableProvider} to overwrite page variables | ||||||
*/ | ||||||
@Retention(RetentionPolicy.RUNTIME) | ||||||
@Target(ElementType.TYPE) | ||||||
public @interface CustomVariableProviderClass { | ||||||
|
||||||
Class<? extends CustomVariableProvider> value(); | ||||||
} | ||||||
|
||||||
/** | ||||||
* The <code>SuiteFilter</code> annotation specifies the suite filter of the Fitnesse suite | ||||||
* to be run, e.g.: fasttests | ||||||
|
@@ -165,6 +176,7 @@ public class FitNesseRunner extends ParentRunner<WikiPage> { | |||||
private FitNesseContext context; | ||||||
private DescriptionFactory descriptionFactory; | ||||||
private List<WikiPage> children; | ||||||
private Map<String,String> customVariables; | ||||||
|
||||||
public FitNesseRunner(Class<?> suiteClass) throws InitializationError { | ||||||
super(suiteClass); | ||||||
|
@@ -219,6 +231,13 @@ protected void collectInitializationErrors(List<Throwable> errors) { | |||||
} catch (Exception e) { | ||||||
errors.add(e); | ||||||
} | ||||||
|
||||||
try { | ||||||
this.customVariables = getCustomVariables(suiteClass); | ||||||
} catch (Exception e) { | ||||||
errors.add(e); | ||||||
} | ||||||
|
||||||
try { | ||||||
this.context = createContext(suiteClass); | ||||||
} catch (Exception e) { | ||||||
|
@@ -320,6 +339,15 @@ protected boolean shouldPreventSystemExit(Class<?> klass) throws Exception { | |||||
return preventSystemExitAnnotation.value(); | ||||||
} | ||||||
|
||||||
|
||||||
protected Map<String,String> getCustomVariables(Class<?> klass) throws Exception { | ||||||
CustomVariableProviderClass customVariableProviderClass = klass.getAnnotation(CustomVariableProviderClass.class); | ||||||
if (null == customVariableProviderClass) { | ||||||
return null; | ||||||
} | ||||||
return customVariableProviderClass.value().newInstance().getCustomVariables(); | ||||||
} | ||||||
|
||||||
protected String getFitNesseDir(Class<?> klass) | ||||||
throws InitializationError { | ||||||
FitnesseDir fitnesseDirAnnotation = klass.getAnnotation(FitnesseDir.class); | ||||||
|
@@ -416,14 +444,21 @@ protected void addExecutionLogListener(RunNotifier notifier, MultipleTestsRunner | |||||
testRunner.addExecutionLogListener(new ConsoleExecutionLogListener()); | ||||||
} | ||||||
|
||||||
protected WikiPage getRootPage() { | ||||||
if (this.customVariables==null) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return context.getRootPage(); | ||||||
} | ||||||
return context.getRootPage(customVariables); | ||||||
} | ||||||
|
||||||
protected List<WikiPage> initChildren() { | ||||||
WikiPage suiteRoot = getSuiteRootPage(); | ||||||
if (suiteRoot == null) { | ||||||
throw new IllegalArgumentException("No page " + this.suiteName); | ||||||
} | ||||||
List<WikiPage> children; | ||||||
if (suiteRoot.getData().hasAttribute("Suite")) { | ||||||
children = new SuiteContentsFinder(suiteRoot, getSuiteFilter(), context.getRootPage()).getAllPagesToRunForThisSuite(); | ||||||
children = new SuiteContentsFinder(suiteRoot, getSuiteFilter(), getRootPage()).getAllPagesToRunForThisSuite(); | ||||||
} else { | ||||||
children = Collections.singletonList(suiteRoot); | ||||||
} | ||||||
|
@@ -460,12 +495,12 @@ protected ContextConfigurator initContextConfigurator() throws InitializationErr | |||||
|
||||||
private WikiPage getSuiteRootPage() { | ||||||
WikiPagePath path = PathParser.parse(this.suiteName); | ||||||
PageCrawler crawler = context.getRootPage().getPageCrawler(); | ||||||
PageCrawler crawler = getRootPage().getPageCrawler(); | ||||||
return crawler.getPage(path); | ||||||
} | ||||||
|
||||||
private MultipleTestsRunner createTestRunner(List<WikiPage> pages) { | ||||||
final PagesByTestSystem pagesByTestSystem = new PagesByTestSystem(pages, context.getRootPage()); | ||||||
final PagesByTestSystem pagesByTestSystem = new PagesByTestSystem(pages, getRootPage()); | ||||||
|
||||||
MultipleTestsRunner runner = new MultipleTestsRunner(pagesByTestSystem, | ||||||
context.testSystemFactory); | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this method also receive the suiteClass?