-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new Attributes: Documentation, Exploratory, KownBug, WorkItem (#7)
- Loading branch information
1 parent
da554bc
commit 21c93b1
Showing
9 changed files
with
259 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using Xunit.Sdk; | ||
|
||
namespace Xunit.Categories | ||
{ | ||
/// <summary> | ||
/// For annotating tests that have a mainly documentative purpose, as sometimes a piece of code says more than a 1000 words API Documentation. | ||
/// </summary> | ||
[TraitDiscoverer(DocumentationDiscoverer.DiscovererTypeName, DiscovererUtil.AssemblyName)] | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] | ||
public class DocumentationAttribute:Attribute,ITraitAttribute | ||
{ | ||
public DocumentationAttribute(string workItemId) | ||
{ | ||
this.WorkItemId = workItemId; | ||
} | ||
|
||
public DocumentationAttribute(long workItemId) | ||
{ | ||
this.WorkItemId = workItemId.ToString(); | ||
} | ||
|
||
public DocumentationAttribute() | ||
{ | ||
|
||
} | ||
|
||
public string WorkItemId { get; private set; } | ||
} | ||
} |
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,23 @@ | ||
using System.Collections.Generic; | ||
using Xunit.Abstractions; | ||
using Xunit.Sdk; | ||
|
||
namespace Xunit.Categories | ||
{ | ||
public class DocumentationDiscoverer : ITraitDiscoverer | ||
{ | ||
internal const string DiscovererTypeName = DiscovererUtil.AssemblyName + "." + nameof(DocumentationDiscoverer); | ||
|
||
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute) | ||
{ | ||
var workItemId = traitAttribute.GetNamedArgument<string>("WorkItemIdId"); | ||
|
||
|
||
yield return new KeyValuePair<string, string>("Category", "Documentation"); | ||
|
||
if (!string.IsNullOrWhiteSpace(workItemId)) | ||
yield return new KeyValuePair<string, string>("Documentation", workItemId); | ||
|
||
} | ||
} | ||
} |
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,31 @@ | ||
using System; | ||
using Xunit.Sdk; | ||
|
||
namespace Xunit.Categories | ||
{ | ||
/// <summary> | ||
/// For tests that have a exploratory purpose like trying out an unknown API. Not neccessarily relating to your own code. | ||
/// </summary> | ||
/// <example>trying out LINQ for the first time, writing a piece of code to understand IEnumerable.Take and Skip.</example> | ||
[TraitDiscoverer(ExploratoryDiscoverer.DiscovererTypeName, DiscovererUtil.AssemblyName)] | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] | ||
public class ExploratoryAttribute:Attribute,ITraitAttribute | ||
{ | ||
public ExploratoryAttribute(string workItemId) | ||
{ | ||
this.WorkItemId = workItemId; | ||
} | ||
|
||
public ExploratoryAttribute(long workItemId) | ||
{ | ||
this.WorkItemId = workItemId.ToString(); | ||
} | ||
|
||
public ExploratoryAttribute() | ||
{ | ||
|
||
} | ||
|
||
public string WorkItemId { get; private set; } | ||
} | ||
} |
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,23 @@ | ||
using System.Collections.Generic; | ||
using Xunit.Abstractions; | ||
using Xunit.Sdk; | ||
|
||
namespace Xunit.Categories | ||
{ | ||
public class ExploratoryDiscoverer : ITraitDiscoverer | ||
{ | ||
internal const string DiscovererTypeName = DiscovererUtil.AssemblyName + "." + nameof(ExploratoryDiscoverer); | ||
|
||
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute) | ||
{ | ||
var workItemId = traitAttribute.GetNamedArgument<string>("WorkItemIdId"); | ||
|
||
|
||
yield return new KeyValuePair<string, string>("Category", "Exploratory"); | ||
|
||
if (!string.IsNullOrWhiteSpace(workItemId)) | ||
yield return new KeyValuePair<string, string>("Exploratory", workItemId); | ||
|
||
} | ||
} | ||
} |
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,30 @@ | ||
using System; | ||
using Xunit.Sdk; | ||
|
||
namespace Xunit.Categories | ||
{ | ||
/// <summary> | ||
/// For failing tests relating to known bugs that should not fail a build | ||
/// </summary> | ||
[TraitDiscoverer(KnownBugDiscoverer.DiscovererTypeName, DiscovererUtil.AssemblyName)] | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] | ||
public class KnownBugAttribute:Attribute,ITraitAttribute | ||
{ | ||
public KnownBugAttribute(string id) | ||
{ | ||
this.Id = id; | ||
} | ||
|
||
public KnownBugAttribute(long id) | ||
{ | ||
this.Id = id.ToString(); | ||
} | ||
|
||
public KnownBugAttribute() | ||
{ | ||
|
||
} | ||
|
||
public string Id { get; private set; } | ||
} | ||
} |
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,23 @@ | ||
using System.Collections.Generic; | ||
using Xunit.Abstractions; | ||
using Xunit.Sdk; | ||
|
||
namespace Xunit.Categories | ||
{ | ||
public class KnownBugDiscoverer : ITraitDiscoverer | ||
{ | ||
internal const string DiscovererTypeName = DiscovererUtil.AssemblyName + "." + nameof(KnownBugDiscoverer); | ||
|
||
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute) | ||
{ | ||
var bugId = traitAttribute.GetNamedArgument<string>("Id"); | ||
|
||
|
||
yield return new KeyValuePair<string, string>("Category", "KnownBug"); | ||
|
||
if (!string.IsNullOrWhiteSpace(bugId)) | ||
yield return new KeyValuePair<string, string>("KnownBug", bugId); | ||
|
||
} | ||
} | ||
} |
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,30 @@ | ||
using System; | ||
using Xunit.Sdk; | ||
|
||
namespace Xunit.Categories | ||
{ | ||
/// <summary> | ||
/// For annotating tests that relate to a specific work item, not neccessarily a bug. | ||
/// </summary> | ||
[TraitDiscoverer(WorkItemDiscoverer.DiscovererTypeName, DiscovererUtil.AssemblyName)] | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] | ||
public class WorkItemAttribute:Attribute,ITraitAttribute | ||
{ | ||
public WorkItemAttribute(string workItemId) | ||
{ | ||
this.WorkItemId = workItemId; | ||
} | ||
|
||
public WorkItemAttribute(long workItemId) | ||
{ | ||
this.WorkItemId = workItemId.ToString(); | ||
} | ||
|
||
public WorkItemAttribute() | ||
{ | ||
|
||
} | ||
|
||
public string WorkItemId { get; private set; } | ||
} | ||
} |
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,23 @@ | ||
using System.Collections.Generic; | ||
using Xunit.Abstractions; | ||
using Xunit.Sdk; | ||
|
||
namespace Xunit.Categories | ||
{ | ||
public class WorkItemDiscoverer : ITraitDiscoverer | ||
{ | ||
internal const string DiscovererTypeName = DiscovererUtil.AssemblyName + "." + nameof(WorkItemDiscoverer); | ||
|
||
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute) | ||
{ | ||
var workItemId = traitAttribute.GetNamedArgument<string>("WorkItemIdId"); | ||
|
||
|
||
yield return new KeyValuePair<string, string>("Category", "WorkItem"); | ||
|
||
if (!string.IsNullOrWhiteSpace(workItemId)) | ||
yield return new KeyValuePair<string, string>("WorkItem", workItemId); | ||
|
||
} | ||
} | ||
} |
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