Why LogManager load log4j.properties from target/test-classes when run TestNG in Eclipse

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Why LogManager load log4j.properties from target/test-classes when run TestNG in Eclipse

Bruce Wen
Hi All,
I am wondering how classpath is decided when run TestNG suite xml file in Eclipse. Why it add target/test-classes in classpath and LogManager load log4j.properties from there rather than target/classes folder.
I hope somebody can help clarify the root reason for that. Thanks!
Bruce Wen
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why LogManager load log4j.properties from target/test-classes when run TestNG in Eclipse

Ralph Goers
If Eclipse (or any other test environment) didn’t add test-classes to the class path how would it find your test classes. They would normally be first in the class path so that files you want to override for testing are picked up. I suspect this is why it is picking up a log4j.properties there instead of the classes directory. In any case, this has little, if anything, to do with Log4j.

Ralph

> On Jun 29, 2017, at 1:36 PM, Bruce Wen <[hidden email]> wrote:
>
> Hi All,
> I am wondering how classpath is decided when run TestNG suite xml file in Eclipse. Why it add target/test-classes in classpath and LogManager load log4j.properties from there rather than target/classes folder.
> I hope somebody can help clarify the root reason for that. Thanks!
> Bruce Wen



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why LogManager load log4j.properties from target/test-classes when run TestNG in Eclipse

Bruce Wen
Hi Ralph,
Thanks for your reply!
I am confused about it because my class file located in src/main/java rather than src/test/java. To raise this in Log4j, I just want to check if somebody has the same confusion and already know the root cause of it.
You are right. I will try to ask Eclipse community for clarification.
Bruce Wen

    On Thursday, June 29, 2017 11:17 PM, Ralph Goers <[hidden email]> wrote:
 

 If Eclipse (or any other test environment) didn’t add test-classes to the class path how would it find your test classes. They would normally be first in the class path so that files you want to override for testing are picked up. I suspect this is why it is picking up a log4j.properties there instead of the classes directory. In any case, this has little, if anything, to do with Log4j.

Ralph

> On Jun 29, 2017, at 1:36 PM, Bruce Wen <[hidden email]> wrote:
>
> Hi All,
> I am wondering how classpath is decided when run TestNG suite xml file in Eclipse. Why it add target/test-classes in classpath and LogManager load log4j.properties from there rather than target/classes folder.
> I hope somebody can help clarify the root reason for that. Thanks!
> Bruce Wen



   
Loading...