Results 1 to 3 of 3

Thread: Logging the currently excecuting method name in Junit Tests

  1. #1
    Join Date
    Dec 2007
    Posts
    11

    Default Logging the currently excecuting method name in Junit Tests

    Hi All,
    This is a general question related to Spring and Junit. I running my unit tests using "AbstractJUnit4SpringContextTests" and Junit. When i am runnig my unit tests, i need to log the method name which it is currently executing. Please help. I tried with Spring AOP but it doesnt worked.

    Thanks.

  2. #2

    Default

    If you are using Junit 4.7 or above, use a @Rule, as in this example:

    @Rule
    public TestName testMethodName = new TestName();


    @Test
    public void testFooForValidBar() throws Throwable {
    logger.debug("starting..." + testMethodName.getMethodName());

  3. #3
    Join Date
    Dec 2007
    Posts
    11

    Default

    I got solution.

    Please refer the below link.
    http://forum.springsource.org/showthread.php?t=64860

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •