All,
I accidentally took this conversation off-line, but I think the final
answer is valuable for posterity:
If you're using JUnit 4, this should work. There's a way to do it in
JUnit 3, as well, but it's more complicated. Good luck,
David Saff
import junit.framework.Test;
import junit.framework.TestSuite;
import org.junit.runner.JUnitCore;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;
public class RunWithLogging {
public static void main(String[] args) {
JUnitCore core = new JUnitCore();
core.addListener(new RunListener() {
@Override
public void testFailure(Failure failure) throws
Exception {
logSomehow(failure);
}
});
core.run(suite());
}
private static Test suite() {
return new TestSuite(Sample.class);
}
private static void logSomehow(Failure failure) {
// TODO: Fill in log4j stuff here
}
}
On 1/12/07, pari krishnan <spa...@ya...> wrote:
> Hi,
>
> I need help..I want to divert assert message to my own log file with log4j.
> I have referred some link that it is not possible to divert assert message
> to log file with log4j as of version Junit 3.8.2.
> Just want to know whether it will support with new version Junit (above 4
> version)?
> Plz help...
> Ur mail will be helpful for me a lot
>
> Thanks & regards
> pari
>
> hat assertions are not logged via Log4J
>
>
> ________________________________
> Here's a new way to find what you're looking for - Yahoo! Answers
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
> _______________________________________________
> Junit-devel mailing list
> Jun...@li...
> https://lists.sourceforge.net/lists/listinfo/junit-devel
>
>
>
|