Closed BilalKhan199 closed 5 months ago
@BilalKhan199 Hi,
As a result of checking the master branch, no issues occur. It seems to have been fixed in version 5.0.3-beta.
using SingleOrDefault.
Please check after update.
public void RemoveTest(IList<Test> tests, Test test, bool deep = true)
{
var item = tests.SingleOrDefault(x => x.Id == test.Id);
if (item == null && deep)
{
foreach (Test t in tests)
{
RemoveTest(t.Children, test);
}
}
tests.Remove(test);
}
Getting NullReferenceException when you try to remove test that does not exist Repo Code
Message: System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace: <>c__DisplayClass57_0.b__0(Test x)
Enumerable.TryGetSingle[TSource](IEnumerable
1 source, Func
2 predicate, Boolean& found) Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func
2 predicate) Report.RemoveTest(IList`1 tests, Test test, Boolean deep) Report.RemoveTest(Test test) ExtentReports.RemoveTest(String name)Expected: should not get any error if test does not exist.