cancel
Showing results for 
Search instead for 
Did you mean: 

Test result status not refreshing

SOLVED
Vec84
Contributor

Test result status not refreshing

I have this function which I have picked up from a few examples online and managed to get it to write to excel with the result of the test that run. However it seems that either it doesn't refresh after every run or it gets the previous result log. I have created a test to test this function which writes log messages and putting the result in the 3 possible outcomes and everything I run it it puts the precious result to excel... Could someone point me in the right direction as I believe I'm using this method incorrectly.


function WriteDataToExcel(fname, sheetName,testTime, errorCount, warnCount)

{



var app = Sys.OleObject("Excel.Application");

var book = app.Workbooks.Open(fname);

var sheet = book.Sheets.Item(sheetName);

var rowCount = sheet.UsedRange.Rows.Count+1;

var columnCount = sheet.UsedRange.Columns.Count;



var Logs;

var Count;

var Name;

var Status = null;



// Obtains the object that holds the list of project logs

Logs = Project.Logs;

Count = Logs.LogItemsCount

// Iterates through the list of project logs

for (var i = 0; i < Count; i++)

{

var LogItem = LogsCol.LogItem(i);

Name = Logs.LogItem(i).Name;

Status = Logs.LogItem.Status;

}



var TestResult = Status;





switch (Status)

{

case 0:

TestResult = "Passed"

break;



case 1:

TestResult = "Warnings"

break;



case 2:

TestResult = "Failed"

break;



default :

TestResult = "Error"

break;

}





app.Cells(rowCount,columnCount-5) = (aqConvert.DateTimeToFormatStr(aqDateTime.Now(), "%d/%m/%y %H:%M"));

app.Cells(rowCount,columnCount-4) = Name;

app.Cells(rowCount,columnCount-3) = TestResult;

app.Cells(rowCount, columnCount-2) = testTime;

app.Cells(rowCount, columnCount-1) = errorCount;

app.Cells(rowCount, columnCount-0) = warnCount;

book.Save();

app.Quit();



}
Tags (1)
2 ACCEPTED SOLUTIONS