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
Disables extension when test execution is skipped #102
Conversation
@@ -45,6 +45,10 @@ public boolean isModeSet() { | |||
return this.mode != null; | |||
} | |||
|
|||
public boolean isSkipTests() { | |||
return Boolean.valueOf(System.getProperty("maven.test.skip", "false")); |
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.
also you can set it by using skipTests
property. If it is set then using -DskipTests
then tests are also skipped.
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.
The thing to check here would be if -DskipTests
does not imply maven.test.skip
set implictly.
Pending tasks:
|
final List<TestResult> actualTestResults = project | ||
.build() | ||
.options() | ||
//.withSystemProperties("maven.test.skip", "true") |
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.
What are we testing here?
@@ -33,7 +33,7 @@ public void afterProjectsRead(MavenSession session) throws MavenExecutionExcepti | |||
|
|||
configuration = Configuration.load(); | |||
|
|||
if (configuration.isDisabled()) { | |||
if (configuration.isDisabled() && configuration.isSkipTests()) { |
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.
isSkipTestsSet
reflects better what is the use case here. It doesn't have to follow the artificial javabean spec.
764040a
to
0b4dc9d
Compare
@@ -28,17 +28,21 @@ | |||
|
|||
private Configuration configuration; | |||
|
|||
private MavenProjectConfigurator mavenProjectConfigurator; |
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.
It is slightly confusing - storing the MavenProjectConfigurator
as a global variable just because of reading system properties. If you retrieve the information from system properties, then it can be used as a public static
method from separated class. The other case would be storing a boolean flag as a information that the ST tool has been initialized (based on information that it has (not) been disabled or the test has (not) been skipped)
f4516e1
to
a83c3dc
Compare
logCapturingStream = new ByteArrayOutputStream(); | ||
PrintStream newPrintStream = new PrintStream(logCapturingStream); | ||
oldPrintStream = System.out; | ||
System.setOut(newPrintStream); |
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.
BuiltProject
from Embedded Maven we are using under the hood in ProjectBuilder
exposes getMavenLog()
. So I was thinking - maybe instead of replacing the output stream to ours for capturing how about making this log available through DSL? This would also let us run those tests not sequentially.
adde2c0
to
f827ef2
Compare
Can you check why the build is failing? |
f827ef2
to
1d559eb
Compare
When using the |
This is how Maven works unfortunately. Other option would be to take one of the most upper projects, like |
b847882
to
e662b9b
Compare
@@ -34,6 +34,8 @@ | |||
private boolean mvnDebugOutput; | |||
private boolean enableSurefireRemoteDebugging = false; | |||
private boolean ignoreBuildFailure = false; | |||
private boolean skipTests = false; | |||
private String mavenLog = "false"; |
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.
This is rather fuzzy. I don't really see a reason to have it as a string / container for the log content and a "boolean flag".
return this; | ||
} | ||
|
||
public BuildConfigurator withMavenLog() { |
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.
It's not really needed. Maven log is always kept in the case of how we use embedded maven, so simple method for retrieving it from the build is enough. This is making it overcomplicated considering how it's done underneath.
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.
Updated
…xecution is skipped.
…ogs for extension verification.
e662b9b
to
b4b671e
Compare
} | ||
|
||
private boolean isSkip() { | ||
return Boolean.valueOf(System.getProperty("maven.test.skip", "false")); |
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.
Please, move these methods outside of this class. The logic retrieves static information - so, they can be static methods.
See this comment: #102 (comment)
@Override | ||
public void afterProjectsRead(MavenSession session) throws MavenExecutionException { | ||
|
||
configuration = Configuration.load(); | ||
|
||
if (configuration.isDisabled()) { | ||
final MavenProjectConfigurator mavenProjectConfigurator = new MavenProjectConfigurator(configuration); |
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.
As I have written above - it is not necessary to create an instance of the class just because of retrieving system properties...
…ality to another class.
d1a273a
to
2c02450
Compare
Changes proposed in this pull request:
maven.test.skip
,skipTests
andskipITs
property honored by Surefire and Failsafe plugins.Fixes #73