Skip to content

Commit

Permalink
test run fix
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-khatko committed Apr 7, 2014
1 parent 9e521ae commit ba648f1
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 60 deletions.
2 changes: 1 addition & 1 deletion CLAPOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ static void junit_update(
TfsCliUpdater updater = new TfsCliUpdater(run, results, _conData);
updater.UpdateResults();
}
} [Verb(Aliases = "enc", Description = "Encrypts provided string to be used in App.config\nUsage: tfs_cli enc <password>")] static void encrypt( [RequiredAttribute, DescriptionAttribute("Password to be encrypted")] string password ) { System.Console.WriteLine(StringEncriptor.Encrypt(password)); System.Environment.Exit(0); } }}
} [Verb(Aliases = "enc", Description = "Encrypts provided string to be used in App.config\nUsage: tfs_cli enc /p=<password>")] static void encrypt( [RequiredAttribute, DescriptionAttribute("Password to be encrypted")] string password ) { System.Console.WriteLine(StringEncriptor.Encrypt(password)); System.Environment.Exit(0); } }}
Expand Down
19 changes: 8 additions & 11 deletions JunitReportParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ public JunitReportParser(string report, string attach)

if (ts == null)
throw new Exception("Could not parse " + report);
string run_comment = String.Concat(ts.Attributes());
string run_comment = String.Join(", ", ts.Attributes());
var testcases = ts.Elements("testcase");
foreach (var testcase in testcases)
{
TfsCliHelper.Debug(string.Format("JunitParseTest: \"{0}\"", testcase.Name));
{
// parsing
string suite = testcase.Attribute("classname").Value;
string test = testcase.Attribute("name").Value;
Expand All @@ -33,20 +32,18 @@ public JunitReportParser(string report, string attach)
string outcome = (failed) ? "Failed" : "Passed";
if (failed)
failure_message = testcase.Descendants("failure").First().Attribute("message").Value;
string comment = testcase.Descendants().First().Value;

string comment = testcase.Descendants().First().Value;
// put to dict
IRunResultProvider run = findRun(suite);
if (run == null)
{
run = new RunResultProvider(suite, "Autotest", "0", run_comment, attach, suite);
_runs[run] = new List<ITestResultProvider>();
_runs[run].Add(new TestResultProvider(test, outcome, suite, comment, null, "Unknown", failure_message, duration));
}
else
{
_runs[run].Add(new TestResultProvider(test, outcome, suite, comment, null, "Unknown", failure_message, duration));
_runs[run] = new List<ITestResultProvider>();
}
_runs[run].Add(new TestResultProvider(test, outcome, suite, comment, null, "Unknown", failure_message, duration));
TfsCliHelper.Debug(string.Format("JunitParseTest: {0} -> [suite={1}] [outcome={2}] [duration={3}] [failure={4}] ",
test, suite, outcome, duration, failure_message
));
}
}

Expand Down
7 changes: 4 additions & 3 deletions TfsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
namespace tfs_cli
{
class TfsApi
{
{
public const int DURATION_MULTIPLIER = 10000000;
private TfsTeamProjectCollection _tfs;
private ConnectionData _conData;
private ITestManagementTeamProject _project;
Expand Down Expand Up @@ -109,7 +110,7 @@ string attach
result.Owner = _tfs.AuthorizedIdentity;
result.RunBy = _tfs.AuthorizedIdentity;
result.DateStarted = DateTime.Now;
result.Duration = new TimeSpan(10000000000 * (long.Parse(duration)));
result.Duration = new TimeSpan(DURATION_MULTIPLIER * (long.Parse(duration) + 1));
result.DateCompleted = DateTime.Now.AddTicks(result.Duration.Ticks);
result.FailureType = (FailureType)Enum.Parse(typeof(FailureType), failure_type);
result.ErrorMessage = error_message;
Expand Down Expand Up @@ -200,7 +201,7 @@ private ITestIterationResult CreateIteration(ITestCaseResult result, string outc
iteration.Outcome = (TestOutcome)Enum.Parse(typeof(TestOutcome), outcome);
iteration.DateStarted = DateTime.Now;
iteration.DateCompleted = DateTime.Now;
iteration.Duration = new TimeSpan(10000 * (int.Parse(duration)));
iteration.Duration = new TimeSpan(DURATION_MULTIPLIER * (long.Parse(duration) + 1));
iteration.Comment = comment;
if (attach != null)
iteration.Attachments.Add(iteration.CreateAttachment(attach));
Expand Down
22 changes: 9 additions & 13 deletions TfsCliUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,24 @@ public void UpdateResults()
connector.Connect();

TfsApi tfsapi = new TfsApi(connector.Collection(), _conData);

Microsoft.TeamFoundation.TestManagement.Client.ITestRun run = tfsapi.CreateRun(
tfsapi.GetSuite(_runRes.Suite()),
_runRes.Title(), _runRes.Comment(),
_runRes.BuildNumber(),
_runRes.Attachment()
);
foreach (ITestResultProvider res in _results)
{
tfsapi.UpdateTestResult
(
tfsapi.GetTestResult
(
tfsapi.CreateRun(
tfsapi.GetSuite(_runRes.Suite()),
_runRes.Title(), _runRes.Comment(),
_runRes.BuildNumber(),
_runRes.Attachment()
),
res.Title()
),
(
tfsapi.GetTestResult(run, res.Title()),
res.Outcome(),
res.Duration(),
res.Comment(),
res.FailureType(),
res.ErrorMessage(),
res.Attachment()
);
);
}
}
}
Expand Down
Binary file modified bin/Release/tfs_cli.exe
Binary file not shown.
Binary file modified bin/Release/tfs_cli.pdb
Binary file not shown.
Binary file removed bin/Release/tfs_cli.vshost.exe
Binary file not shown.
21 changes: 0 additions & 21 deletions bin/Release/tfs_cli.vshost.exe.config

This file was deleted.

11 changes: 0 additions & 11 deletions bin/Release/tfs_cli.vshost.exe.manifest

This file was deleted.

11 changes: 11 additions & 0 deletions report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<testsuite failures="0" tests="2">
<testcase classname="pilot" name="initial" time="0.196592">
<system-out><![CDATA[* use profile "cca_huawei".........................................................passed
]]></system-out>
</testcase>
<testcase classname="pilot" name="use_profile" time="0.019922">
<system-out><![CDATA[* use profile "cca_huawei".........................................................passed
]]></system-out>
</testcase>
</testsuite>

0 comments on commit ba648f1

Please sign in to comment.