none
Loglocation RRS feed

  • Question

  • TestResult test
    foreach (Test test in project.GetTests().Where(x => (x.Name == "mytest")))
    {
       TestResult testResult = test.GetTestResults().Last();
       
    }

       During developping automation tool of WHCK in C#, how can I get the value of LogLogcation?

       When I debug in VS I find this value is a base  non-public members of TestResult, but I can't find the method to get it.

       Thanks in advance.

    Monday, October 8, 2012 7:44 AM

Answers

  • Various log files can be retrieved via TestResult::GetLogs() or Task::GetLogs(). When using looking at the list of returned TestLog, you can look at TestLog::LogType to understand the type of log that you are getting.

    The full path to the source of the log file is not available in the OM API. However, if you are just trying to get the contents of the log file, you can save the log file via TestLog::WriteLogTo(string destination).


    John -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, October 8, 2012 4:16 PM
  • WriteLogTo() must include a name for the file. Looking at your code, I'm assuming logtests is a share. Try changing your code to something like -

    TestLog tl = testResult.GetLogs().First();
    string address = Path.Combine("\\\\testlogs", tl.Name);
    tl.WriteLogTo(address);


    John -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, October 9, 2012 5:57 PM
  • Both the result and the tasks can have logs. the logs at the result level are those that cannot be attributed against a single task.

    I suspect that you will need to find the TASK that has the answers that you are looking for, and use the Task.GetLogFiles() API to look for a log named "nike.wtl"

    something like

    foreach (Task t in <MyTestResult>.GetTasks() )

    {

             TestLog log = t.GetLogFiles.FirstOrDefault( x=>x.Name == "nike.wtl");

             if (log != null) { return log;}

    }


    Thursday, October 11, 2012 5:04 PM

All replies

  • TestResult test
    foreach (Test test in project.GetTests().Where(x => (x.Name == "mytest")))
    {
       TestResult testResult = test.GetTestResults().Last();
       
    }

       During developping automation tool of WHCK in C#, how can I get the value of LogLogcation?

       When I debug in VS I find this value is a base  non-public members of TestResult, but I can't find the method to get it.

       Thanks in advance.


    Additional: I want to gether the test result report in my local folder these result may stored in a WTT log file. The file path is   \\whck.xxx.xxx.com\HCKLogs\\XXXX-XXXX-XXXX-XXXX\...  which stored in the value Loglocation. 
    • Edited by ChowJun Monday, October 8, 2012 8:04 AM
    Monday, October 8, 2012 8:02 AM
  • Various log files can be retrieved via TestResult::GetLogs() or Task::GetLogs(). When using looking at the list of returned TestLog, you can look at TestLog::LogType to understand the type of log that you are getting.

    The full path to the source of the log file is not available in the OM API. However, if you are just trying to get the contents of the log file, you can save the log file via TestLog::WriteLogTo(string destination).


    John -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, October 8, 2012 4:16 PM
  • if (test.GetTestResults().Count > 0)
    {
         string address = "\\logtests";
         TestResult testResult = test.GetTestResults().First();
         testResult.GetLogs().First().WriteLogTo(address);
         Console.WriteLine("||TestStatus:{0}",  test.GetTestResults().Last().Status);
    } 

    Thanks,  I try the WriteLogTo(address),  but  the folder logtests was not create correctly, and I found nothing about log had written in my local.

    Could you show me some tips about how to use WriteLogTo()

    Tuesday, October 9, 2012 7:21 AM
  • WriteLogTo() must include a name for the file. Looking at your code, I'm assuming logtests is a share. Try changing your code to something like -

    TestLog tl = testResult.GetLogs().First();
    string address = Path.Combine("\\\\testlogs", tl.Name);
    tl.WriteLogTo(address);


    John -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, October 9, 2012 5:57 PM
  • Thanks, I collcet all the logs in local, but I can't find the most important report "nike.wtl".

    For example:

    nike.wtl path: "\\serveraddress\HCKLogs\\874D0068-7CB0-4AEC-B7E4-0B1D16845E5F\E5DA79D4-9ADD-48D9-A122-42C36FB51EC5\F656A840-C3E0-42B7-AD50-1A4BDE899FE2\NIKE.wtl",

    I can find the path in "wttEa.log", which recorded all the operation about the test.

    Is there a better way to write down the log to local?

    Thursday, October 11, 2012 5:54 AM
  • Both the result and the tasks can have logs. the logs at the result level are those that cannot be attributed against a single task.

    I suspect that you will need to find the TASK that has the answers that you are looking for, and use the Task.GetLogFiles() API to look for a log named "nike.wtl"

    something like

    foreach (Task t in <MyTestResult>.GetTasks() )

    {

             TestLog log = t.GetLogFiles.FirstOrDefault( x=>x.Name == "nike.wtl");

             if (log != null) { return log;}

    }


    Thursday, October 11, 2012 5:04 PM
  • Yes,great. I looked for result in the test, however it was in the task. Thanks for John and Jeff,

    ------------------

    Chow

    • Edited by ChowJun Friday, October 12, 2012 3:14 AM
    Friday, October 12, 2012 2:29 AM