You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Farrukh Najmi <fa...@wellfleetsoftware.com> on 2011/10/05 18:26:42 UTC

maven-surefire-plugin redirecting System.err and showing delayed output from junit tests

Sometime in the recent past I noticed that when I run my projects junit 
tests via maven-surefire-plugin I no longer see the log messages or 
println statements sent to System.err until *after* the test completes. 
Since these message are important while debugging a test I need to see 
them as the test executes. I noticed in the debugger that System.err is 
redirected to some surefire specific class.

Can any one tell me how I to get back the old behavior where all log 
messages and output to System.err is displayed on the console as it 
happens in real time?

Thank you for your help.

-- 
Regards,
Farrukh Najmi

Web: http://www.wellfleetsoftware.com



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven-surefire-plugin redirecting System.err and showing delayed output from junit tests

Posted by Kristian Rosenvold <kr...@gmail.com>.
You would have to try version 2.8.1; I will take a look at this for
2.11.

Kristian



to., 03.11.2011 kl. 08.38 -0700, skrev farrukh_najmi:
> Note that I have tried this with both maven-surefire-plugin 2.9 and 2.10 and
> there is no difference.
> 
> --
> View this message in context: http://maven.40175.n5.nabble.com/maven-surefire-plugin-redirecting-System-err-and-showing-delayed-output-from-junit-tests-tp4873335p4961409.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven-surefire-plugin redirecting System.err and showing delayed output from junit tests

Posted by farrukh_najmi <fa...@wellfleetsoftware.com>.
Note that I have tried this with both maven-surefire-plugin 2.9 and 2.10 and
there is no difference.

--
View this message in context: http://maven.40175.n5.nabble.com/maven-surefire-plugin-redirecting-System-err-and-showing-delayed-output-from-junit-tests-tp4873335p4961409.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven-surefire-plugin redirecting System.err and showing delayed output from junit tests

Posted by farrukh_najmi <fa...@wellfleetsoftware.com>.
@Kristian, thank you for your kind help. More below...

I have finally solved my immediate problem. The problem was introduced when
I made a change to a spring configuration file that caused an exception
during the spring context creation by spring due to the
*@org.springframework.test.context.ContextConfiguration* in my JUnit test
which extended
*org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests*
class.

When this happened all my tests failed but no interim output was produced as
normally expected. Thus the entire suite took a very long time to run (with
all tests failing on context creation) to run while not giving any feedback
on individual test status.

After all tests failed the entire buffered output was spit out in one big
burst it seems.

When I fixed my spring context file issue everything started working
normally and I strarted seeing interim passed, FAILED messages on the
console.

maven-surefire-plugin version did not seem to make any different with 2.8,
2.9, 2.10. I did not try 2.8.1.

As you can gather the scenario is rather complex and I do not have time to
make a reproducable test case. Should I still file an issue? I am not sure
whether the problem is a surefire-plugin issue of a spring-test issue.

Thanks for your advice and help.

--
View this message in context: http://maven.40175.n5.nabble.com/maven-surefire-plugin-redirecting-System-err-and-showing-delayed-output-from-junit-tests-tp4873335p4962045.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven-surefire-plugin redirecting System.err and showing delayed output from junit tests

Posted by Kristian Rosenvold <kr...@gmail.com>.
System.err will always be redirected in the forked VM, there is no
setting to avoid that. But the output should be piped through to the
surefire-plugin and output from there instead, which should be identical
(but quite obviously isn't totally the same ATM.)

If you want this fixed you should probably do what I suggested in my
original response, file a bug report with a small sample project to
demonstrate your problem.

Kristian



to., 03.11.2011 kl. 08.36 -0700, skrev farrukh_najmi:
> This issue has become a productivity loss nightmare for me. Debugger shows
> that System.err is set to:
> 
> org.apache.maven.surefirereport.ConsoleOutputCapture$ForwardingPrintStream
> 
> Using useFile plugin config param with value false has no effect and
> System.err is still redirected.
> 
> What magic do I need to make sure that System.err does not get redirected?
> 
> Please help me out of this hole. Thanks.
> 
> 
> Kristian Rosenvold-4 wrote:
> > 
> > There were some changes in the capture/buffering algorithm for test 
> > output for surefire 2.9, which might be what you are seeing. If you are 
> > running your tests in parallel,
> > this is the intended behaviour, but I assume there might have been some 
> > change in the serial run-mode too, which is probably unintentional. This 
> > is not the
> > kind of stuff our (extensive) test-cases would spot, since the end 
> > behaviour is correct.
> > 
> > I think you should file an issue for this at 
> > http://jira.codehaus.org/browse/SUREFIRE, preferably attaching a small 
> > sample project that demonstrates the problem.
> > 
> > You can use this project as a template for creating an example project 
> > https://svn.apache.org/repos/asf/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit47-redirect-output*
> > 
> > 
> > Kristian
> > 
> > *
> > 
> 
> 
> --
> View this message in context: http://maven.40175.n5.nabble.com/maven-surefire-plugin-redirecting-System-err-and-showing-delayed-output-from-junit-tests-tp4873335p4961403.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven-surefire-plugin redirecting System.err and showing delayed output from junit tests

Posted by farrukh_najmi <fa...@wellfleetsoftware.com>.
This issue has become a productivity loss nightmare for me. Debugger shows
that System.err is set to:

org.apache.maven.surefirereport.ConsoleOutputCapture$ForwardingPrintStream

Using useFile plugin config param with value false has no effect and
System.err is still redirected.

What magic do I need to make sure that System.err does not get redirected?

Please help me out of this hole. Thanks.


Kristian Rosenvold-4 wrote:
> 
> There were some changes in the capture/buffering algorithm for test 
> output for surefire 2.9, which might be what you are seeing. If you are 
> running your tests in parallel,
> this is the intended behaviour, but I assume there might have been some 
> change in the serial run-mode too, which is probably unintentional. This 
> is not the
> kind of stuff our (extensive) test-cases would spot, since the end 
> behaviour is correct.
> 
> I think you should file an issue for this at 
> http://jira.codehaus.org/browse/SUREFIRE, preferably attaching a small 
> sample project that demonstrates the problem.
> 
> You can use this project as a template for creating an example project 
> https://svn.apache.org/repos/asf/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit47-redirect-output*
> 
> 
> Kristian
> 
> *
> 


--
View this message in context: http://maven.40175.n5.nabble.com/maven-surefire-plugin-redirecting-System-err-and-showing-delayed-output-from-junit-tests-tp4873335p4961403.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven-surefire-plugin redirecting System.err and showing delayed output from junit tests

Posted by Kristian Rosenvold <kr...@gmail.com>.
Den 05.10.2011 18:26, skrev Farrukh Najmi:
>
> Sometime in the recent past I noticed that when I run my projects 
> junit tests via maven-surefire-plugin I no longer see the log messages 
> or println statements sent to System.err until *after* the test 
> completes. Since these message are important while debugging a test I 
> need to see them as the test executes. I noticed in the debugger that 
> System.err is redirected to some surefire specific class.
>
> Can any one tell me how I to get back the old behavior where all log 
> messages and output to System.err is displayed on the console as it 
> happens in real time?
>
> Thank you for your help.
>
There were some changes in the capture/buffering algorithm for test 
output for surefire 2.9, which might be what you are seeing. If you are 
running your tests in parallel,
this is the intended behaviour, but I assume there might have been some 
change in the serial run-mode too, which is probably unintentional. This 
is not the
kind of stuff our (extensive) test-cases would spot, since the end 
behaviour is correct.

I think you should file an issue for this at 
http://jira.codehaus.org/browse/SUREFIRE, preferably attaching a small 
sample project that demonstrates the problem.

You can use this project as a template for creating an example project 
https://svn.apache.org/repos/asf/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit47-redirect-output*


Kristian

*




Re: maven-surefire-plugin redirecting System.err and showing delayed output from junit tests

Posted by Wayne Fay <wa...@gmail.com>.
> Can any one tell me how I to get back the old behavior where all log
> messages and output to System.err is displayed on the console as it happens
> in real time?

Did you check the documentation for the surefire plugin?
http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html

Try the useFile parameter.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org