Navigation Menu

Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

Commit

Permalink
closes #18 - provide ability to remove a test
Browse files Browse the repository at this point in the history
  • Loading branch information
anshooarora committed Mar 28, 2017
1 parent 5a1f613 commit dce7875
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ExtentReports/ExtentReports/ExtentReports.cs
Expand Up @@ -121,6 +121,15 @@ public ExtentTest CreateTest(GherkinKeyword gherkinKeyword, string name, string
return extentTest;
}

/// <summary>
/// Allows removing a test from the list
/// </summary>
/// <param name="test"><see cref="ExtentTest"/> An ExtentTest object</param>
public void RemoveTest(ExtentTest test)
{
base.RemoveTest(test.GetModel());
}

/// <summary>
/// Writes test information from the started reporters to their output view
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions ExtentReports/ExtentReports/Model/AbstractStructure.cs
Expand Up @@ -26,6 +26,11 @@ public void Add(T t)
_list.Add(t);
}

public void Remove(T t)
{
_list.Remove(t);
}

public T Get(int index)
{
return _list[index];
Expand Down
25 changes: 25 additions & 0 deletions ExtentReports/ExtentReports/Model/Report.cs
Expand Up @@ -62,6 +62,31 @@ protected void CreateTest(Test test)
_reporterCollection.ForEach(x => x.OnTestStarted(test));
}

[MethodImpl(MethodImplOptions.Synchronized)]
protected void RemoveTest(Test test)
{
foreach (var t in _testCollection)
{
if (t.TestId == test.TestId)
{
_testCollection.Remove(t);
return;
}

if (t.HasChildren())
{
foreach (var n in t.NodeContext().GetAllItems())
{
if (n.TestId == test.TestId)
{
t.NodeContext().Remove(n);
return;
}
}
}
}
}

[MethodImpl(MethodImplOptions.Synchronized)]
internal void AddNode(Test node)
{
Expand Down

0 comments on commit dce7875

Please sign in to comment.