Manual Tests logs are not written to file

Issue #380 resolved
Desrever Nu created an issue

For an example, take TestWrappers :

Despite setting the global variable at the beginning of the test

 //Set the logging directory
        Global.sessionLogFolders = Utils.generateLogPath(TestWrappers.class.getSimpleName());

which generates the ouput

09:35:51.347 c.n.n.u.Utils 275 INFO  - Logging folder :  tests_TestWrappers_1427186151346/

I can't find the output of the test.

Would it be possible to save log files to the directory declared in Global.sessionLogFolders ?

Comments (8)

  1. Benjamin Cordes

    see TestWrappers in static block. Test_logback.xml defines "<property scope="context" name="logfolder" value="testlogs" />"

    this file is defined in Settings

  2. Desrever Nu reporter
    • The folder should be under logs/
    • The name of the folder should contain the name of the test
    • At the end of the test I want to be able to print the path to the log file where the current session wrote into
    • Do we need to create a different xml file for each manual test?
    • I do not thing the xml belongs in /allconfig , I think it is a resource
    • in Settings.java a comment explaining the variable is missing

    If you want to postpone the changes above to a future iteration, then - restore the old logger that was giving us control over the filename without creating a new xml file - open a new ticket with details in a future version

  3. Benjamin Cordes

    I've implemented this using one of logback features called SiftingAppender. There is an example in TestLogging. Based on the configured testID a different file will be used. So there is only one xml file, which defines a pattern to be used.

    MDC.put("testID", "TestExample");
    LOG.info("<<<<<<<<<<<<<<<<"); // this will use TestExample.log
    
    MDC.put("testID", "TestABCXYZ"); // this will use TestABCXYZ.log
    LOG.info("*****************");
    

    needed definition at the thop

    static {
            System.setProperty("logback.configurationFile", Settings.TEST_LOGXML);
    
        }
    
  4. Desrever Nu reporter

    Elegant solution and nice example in the Test.

    I updated the example in TestLogging and all the manual tests now log to the folder logs/tests/ . Each file its composed by the name of the class and the timestamp of execution ( See InitTests.setLoggingFilename(Logger log) )

  5. Log in to comment