allure-csharp icon indicating copy to clipboard operation
allure-csharp copied to clipboard

Await issue

Open unickq opened this issue 5 years ago • 3 comments

Hey there.

This is possible duplicate of https://github.com/allure-framework/allure-csharp/issues/83. But I don't see example code there, so not sure.

The issue here - test with await TestError throws error when Step is trying to find it's parent in AllureStorage.cs line58

System.ArgumentNullException : Value cannot be null.
Parameter name: key
   at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key, TValue& value)
   at System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key)
   at Allure.Commons.Storage.AllureStorage.Get[T](String uuid)
   at Allure.Commons.Storage.AllureStorage.AddStep(String parentUuid, String uuid, StepResult stepResult)
   at Allure.Commons.AllureLifecycle.StartStep(String parentUuid, String uuid, StepResult stepResult)
   at Allure.Commons.AllureLifecycle.StartStep(String uuid, StepResult result)

Below are code examples you can reproduce it.

public class Tests {
 private AllureWrapper allure = new AllureWrapper();

 [SetUp]
 public void SetUp() {
  AllureLifecycle.Instance.CleanupResultDirectory();
  allure.SetUp();
 }

 [TearDown]
 public void TearDown() {
  allure.TearDown();
 }

 // The test which is failing
 [Test]
 public async Task TestError() {
  await Task.Delay(1000);
  allure.Step();
 }

 // Same test without error
 [Test]
 public async Task TestNoError() {
  Task.Delay(1000).GetAwaiter().GetResult();
  allure.Step();
 }
}
public class AllureWrapper {
 private TestResultContainer testResultContainer = new TestResultContainer {
  uuid = "cont"
 };
 private TestResult testResult = new TestResult {
  uuid = "test"
 };


 public void SetUp() {
  AllureLifecycle.Instance.StartTestContainer(testResultContainer);
  AllureLifecycle.Instance.StartTestCase(testResultContainer.uuid, testResult);
 }


 public void TearDown() {
  AllureLifecycle.Instance.StartTestCase(testResult);
  AllureLifecycle.Instance.StopTestContainer(testResultContainer.uuid);

  AllureLifecycle.Instance.WriteTestContainer(testResultContainer.uuid);
  AllureLifecycle.Instance.WriteTestCase(testResult.uuid);
 }

 public void Step(string name = "Step") {
  var step = new StepResult() {
   name = name
  };
  AllureLifecycle.Instance.StartStep(Guid.NewGuid().ToString(), step);
  AllureLifecycle.Instance.StopStep();
 }
}

Allure.Commons 3.0.0.10

unickq avatar May 08 '20 08:05 unickq

"#83" - yes it is the same issue. Thank you for clear description and steps to repro

VictorYakushenko avatar Jun 28 '20 22:06 VictorYakushenko

Hello! When are you going to solve this problem? I am really looking forward to it :). Thank! Respectfully!

EvgenyMarchuk avatar Jul 28 '20 07:07 EvgenyMarchuk

any updates here?

NaZaRKIN123 avatar Mar 21 '22 12:03 NaZaRKIN123

any updates till now?

Hello everyone! Should be fixed in upcoming preview release with changes authored by @overlord I'll write as soon as I upload it.

neparij avatar Dec 30 '22 12:12 neparij

2.9.4-preview.1 package

neparij avatar Dec 30 '22 13:12 neparij

Some additional fixes comes in 2.9.4-preview.2 package

neparij avatar Jan 09 '23 09:01 neparij

Should be fixed in 2.10.0. Please, leave me a comment here in case it's not.

delatrie avatar Oct 16 '23 14:10 delatrie