Forum Discussion

Mia's avatar
Mia
Contributor
10 years ago

Creating own result file, passing test result into .txt file

Hello,

 

my goal is to create simple result file, which can be after test execution displayed in command prompt. I have a test run which consists from many test items, and all I want to see on the first place is just the test item name and test item result. I know how to get the test item name and result (I use a General event OnStopTest for getting the name and restult). But I couldn't find any way how to save these information into one file (the best would be .txt so the command prompt could show the file content). Is there someone who could help me with this?

 

Thank you

 

Mia.

  • I found a solution using the following function.

     

     

    function OwnResult_OnStopTest(Sender)
    {
      var kwName = Project.TestItems.Current.Name;
      var sPath = "c:\\IDC\\QAResult\\AutomatedTestsResult.txt";
      
      if (Log.ErrCount > 0)
        strTestResult = "FAILED";
      else if (Log.WrnCount > 0 && Log.ErrCount == 0)
        strTestResult = strTestResult != "FAILED" ? "WARNING" : "FAILED";
      else
        strTestResult = strTestResult != "FAILED" ?
                          (strTestResult != "WARNING" ? "PASSED" : "WARNING") : "FAILED";
    
      Log.Message(strTestResult + "... \t" + kwName);  
    
      if (!aqFile.Exists(sPath)) 
        aqFile.Create(sPath);
      aqFile.WriteToTextFile(sPath, strTestResult + "... \t " + kwName + "\r\n", aqFile.ctANSI, false);
    
    }

     

  • Mia's avatar
    Mia
    Contributor

    I found a solution using the following function.

     

     

    function OwnResult_OnStopTest(Sender)
    {
      var kwName = Project.TestItems.Current.Name;
      var sPath = "c:\\IDC\\QAResult\\AutomatedTestsResult.txt";
      
      if (Log.ErrCount > 0)
        strTestResult = "FAILED";
      else if (Log.WrnCount > 0 && Log.ErrCount == 0)
        strTestResult = strTestResult != "FAILED" ? "WARNING" : "FAILED";
      else
        strTestResult = strTestResult != "FAILED" ?
                          (strTestResult != "WARNING" ? "PASSED" : "WARNING") : "FAILED";
    
      Log.Message(strTestResult + "... \t" + kwName);  
    
      if (!aqFile.Exists(sPath)) 
        aqFile.Create(sPath);
      aqFile.WriteToTextFile(sPath, strTestResult + "... \t " + kwName + "\r\n", aqFile.ctANSI, false);
    
    }

     

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    //JScript
    fso = new ActiveXObject('Scripting.FileSystemObject');
    var fsoTextFile = fso.OpenTextFile(Log.Path + 'logresults.txt', 8, true);
    fsoTextFile.WriteLine(someVariableToWrite);
    fsoTextFile.Close();