-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blame Sequence File Changes #1716
Merged
vagisha-nidhi
merged 6 commits into
microsoft:master
from
vagisha-nidhi:BlameReaderChanges
Aug 6, 2018
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
353998e
Blame Sequence File Changes
vagisha-nidhi 80a2cae
Merge branch 'master' of https://github.com/Microsoft/vstest into Bla…
vagisha-nidhi 4b45407
PR comment changes
vagisha-nidhi d155f3f
Added UTs
vagisha-nidhi 908297c
Change in UTs
vagisha-nidhi abf651d
Minor Changes
vagisha-nidhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameTestObject.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.TestPlatform.Extensions.BlameDataCollector | ||
{ | ||
using System; | ||
using System.IO; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; | ||
|
||
public class BlameTestObject | ||
{ | ||
private Guid id; | ||
private string fullyQualifiedName; | ||
private string source; | ||
private bool isCompleted; | ||
private string displayName; | ||
|
||
#region Constructor | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BlameTestObject"/> class. | ||
/// </summary> | ||
public BlameTestObject() | ||
{ | ||
// Default constructor | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BlameTestObject"/> class. | ||
/// </summary> | ||
/// <param name="fullyQualifiedName"> | ||
/// Fully qualified name of the test case. | ||
/// </param> | ||
/// <param name="executorUri"> | ||
/// The Uri of the executor to use for running this test. | ||
/// </param> | ||
/// <param name="source"> | ||
/// Test container source from which the test is discovered. | ||
/// </param> | ||
public BlameTestObject(string fullyQualifiedName, Uri executorUri, string source) | ||
{ | ||
ValidateArg.NotNullOrEmpty(fullyQualifiedName, "fullyQualifiedName"); | ||
ValidateArg.NotNull(executorUri, "executorUri"); | ||
ValidateArg.NotNullOrEmpty(source, "source"); | ||
|
||
this.Id = Guid.Empty; | ||
this.FullyQualifiedName = fullyQualifiedName; | ||
this.ExecutorUri = executorUri; | ||
this.Source = source; | ||
this.IsCompleted = false; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BlameTestObject"/> class. | ||
/// </summary> | ||
/// <param name="testCase"> | ||
/// The test case | ||
/// </param> | ||
public BlameTestObject(TestCase testCase) | ||
{ | ||
this.Id = testCase.Id; | ||
this.FullyQualifiedName = testCase.FullyQualifiedName; | ||
this.ExecutorUri = testCase.ExecutorUri; | ||
this.Source = testCase.Source; | ||
this.DisplayName = testCase.DisplayName; | ||
this.IsCompleted = false; | ||
} | ||
|
||
#endregion | ||
|
||
#region Properties | ||
|
||
/// <summary> | ||
/// Gets or sets the id of the test case. | ||
/// </summary> | ||
public Guid Id | ||
{ | ||
get | ||
{ | ||
return this.id; | ||
} | ||
|
||
set | ||
{ | ||
this.id = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the fully qualified name of the test case. | ||
/// </summary> | ||
public string FullyQualifiedName | ||
{ | ||
get | ||
{ | ||
return this.fullyQualifiedName; | ||
} | ||
|
||
set | ||
{ | ||
this.fullyQualifiedName = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the Uri of the Executor to use for running this test. | ||
/// </summary> | ||
public Uri ExecutorUri | ||
{ | ||
get; set; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the test container source from which the test is discovered. | ||
/// </summary> | ||
public string Source | ||
{ | ||
get | ||
{ | ||
return this.source; | ||
} | ||
|
||
set | ||
{ | ||
this.source = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether test case is completed or not. | ||
/// </summary> | ||
public bool IsCompleted | ||
{ | ||
get | ||
{ | ||
return this.isCompleted; | ||
} | ||
|
||
set | ||
{ | ||
this.isCompleted = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the display name of the test case | ||
/// </summary> | ||
public string DisplayName | ||
{ | ||
get | ||
{ | ||
return this.displayName; | ||
} | ||
|
||
set | ||
{ | ||
this.displayName = value; | ||
} | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
namespace Microsoft.TestPlatform.Extensions.BlameDataCollector | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Xml; | ||
|
@@ -46,18 +47,23 @@ protected XmlReaderWriter(IFileHelper fileHelper) | |
#endregion | ||
|
||
/// <summary> | ||
/// Adds tests to document and saves document to file | ||
/// Writes test Sequence to file. | ||
/// Protected for testing purposes | ||
/// </summary> | ||
/// <param name="testSequence"> | ||
/// The test Sequence. | ||
/// Sequence of Guids | ||
/// </param> | ||
/// <param name="testObjectDictionary"> | ||
/// Dictionary of test objects | ||
/// </param> | ||
/// <param name="filePath"> | ||
/// The file Path. | ||
/// </param> | ||
/// <returns>File path</returns> | ||
public string WriteTestSequence(List<TestCase> testSequence, string filePath) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
check for outcome/result There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no outcome field in TestCase object. |
||
public string WriteTestSequence(List<Guid> testSequence, Dictionary<Guid, BlameTestObject> testObjectDictionary, string filePath) | ||
{ | ||
ValidateArg.NotNull(testSequence, nameof(testSequence)); | ||
ValidateArg.NotNull(testObjectDictionary, nameof(testObjectDictionary)); | ||
ValidateArg.NotNullOrEmpty(filePath, nameof(filePath)); | ||
|
||
filePath = filePath + ".xml"; | ||
|
@@ -68,13 +74,20 @@ public string WriteTestSequence(List<TestCase> testSequence, string filePath) | |
var blameTestRoot = xmlDocument.CreateElement(Constants.BlameRootNode); | ||
xmlDocument.AppendChild(xmlDeclaration); | ||
|
||
foreach (var testCase in testSequence) | ||
foreach (var testGuid in testSequence) | ||
{ | ||
var testElement = xmlDocument.CreateElement(Constants.BlameTestNode); | ||
testElement.SetAttribute(Constants.TestNameAttribute, testCase.FullyQualifiedName); | ||
testElement.SetAttribute(Constants.TestSourceAttribute, testCase.Source); | ||
if (testObjectDictionary.ContainsKey(testGuid)) | ||
{ | ||
var testObject = testObjectDictionary[testGuid]; | ||
|
||
blameTestRoot.AppendChild(testElement); | ||
var testElement = xmlDocument.CreateElement(Constants.BlameTestNode); | ||
testElement.SetAttribute(Constants.TestNameAttribute, testObject.FullyQualifiedName); | ||
testElement.SetAttribute(Constants.TestDisplayNameAttribute, testObject.DisplayName); | ||
testElement.SetAttribute(Constants.TestSourceAttribute, testObject.Source); | ||
testElement.SetAttribute(Constants.TestCompletedAttribute, testObject.IsCompleted.ToString()); | ||
|
||
blameTestRoot.AppendChild(testElement); | ||
} | ||
} | ||
|
||
xmlDocument.AppendChild(blameTestRoot); | ||
|
@@ -91,7 +104,7 @@ public string WriteTestSequence(List<TestCase> testSequence, string filePath) | |
/// </summary> | ||
/// <param name="filePath">The path of test sequence file</param> | ||
/// <returns>Test Case List</returns> | ||
public List<TestCase> ReadTestSequence(string filePath) | ||
public List<BlameTestObject> ReadTestSequence(string filePath) | ||
{ | ||
ValidateArg.NotNull(filePath, nameof(filePath)); | ||
|
||
|
@@ -100,7 +113,7 @@ public List<TestCase> ReadTestSequence(string filePath) | |
throw new FileNotFoundException(); | ||
} | ||
|
||
var testCaseList = new List<TestCase>(); | ||
var testCaseList = new List<BlameTestObject>(); | ||
try | ||
{ | ||
// Reading test sequence | ||
|
@@ -113,11 +126,13 @@ public List<TestCase> ReadTestSequence(string filePath) | |
var root = xmlDocument.LastChild; | ||
foreach (XmlNode node in root) | ||
{ | ||
var testCase = new TestCase | ||
var testCase = new BlameTestObject | ||
{ | ||
FullyQualifiedName = | ||
node.Attributes[Constants.TestNameAttribute].Value, | ||
Source = node.Attributes[Constants.TestSourceAttribute].Value | ||
Source = node.Attributes[Constants.TestSourceAttribute].Value, | ||
DisplayName = node.Attributes[Constants.TestDisplayNameAttribute].Value, | ||
IsCompleted = node.Attributes[Constants.TestCompletedAttribute].Value == "True" ? true : false | ||
}; | ||
testCaseList.Add(testCase); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this>?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will have to check for entire dictionary if any test remains incomplete to decide if sequence is to be written to file. This makes an easier check.