Page 1 of 1

log before first iteration

Posted: Wed Mar 15, 2017 12:07 pm
by kathrin
Hello,

I often use SQL-DataConnectors in my solution as DataSource for multiple iterations. I would like to show the used data in the report before the first iteration starts. So it would be possible to see wich data is used in the iteration without toggeling all to "testdata".

The function (see below) works fine but i don't know where to put it to achieve that. In the report i want somthing like:

Testcase
Data-Table
Iteration 1
Iteration 2

Thanks, Kathrin

function to create the report:

Code: Select all

TestCaseNode tc = TestCaseNode.Current;
SqlDataConnector con = (SqlDataConnector)tc.DataSource;

StringBuilder table = new StringBuilder();

ColumnCollection cols;
RowCollection rows;
con.LoadData(out cols, out rows);
				        		
table.Append("<table width='100%' border='1'" +
                " style='border-collapse:collapse;" +
                "border-color:#000000;" +
                "border-width:1px;'>");
table.Append("<tr>");
cols.ToList().ForEach(c => {
  table.Append("<th>" + c.Name + "</th>");
});

table.Append("</tr>");

rows.ToList().ForEach(a => {
  table.Append("<tr>");
  cols.ToList().ForEach(c => {
    table.Append("<td>" + a[c.Name] + "</td>");
  });
  table.Append("</tr>");
});
							  
table.Append("</table>");

Report.LogHtml(ReportLevel.Info, "DataSource", table.ToString());

Re: log before first iteration

Posted: Wed Mar 22, 2017 12:44 pm
by asdf
Hi Kathrin,

Have you tried to simply log the information to the report directly with a Report-action at the beginning of your tests?
Variable.png
You could also log the variable directly in your program.cs before the TestSuite starts.
2017-03-22 12_43_47-UsedVar - Ranorex Studio.png
Hope this helps.

Kind regards,
asdf