Skip to content
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

Argument null exception when decorating Setup fixtures or extending classes #325

Open
1 of 3 tasks
vladdex opened this issue Jan 19, 2023 · 2 comments · Fixed by #380
Open
1 of 3 tasks

Argument null exception when decorating Setup fixtures or extending classes #325

vladdex opened this issue Jan 19, 2023 · 2 comments · Fixed by #380
Labels

Comments

@vladdex
Copy link

vladdex commented Jan 19, 2023

I'm submitting a ...

  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?

If the [AllureNunit] attribute is added to a [SetupFixture] or a [TestFixture] that only contains [OneTimeSetup] methods (for example a BaseTest class which is extended by all test calsses) then a ArgumentNullException is thrown at runtime

   at System.ThrowHelper.ThrowArgumentNullException(String name)
   at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key, TValue& value)
   at System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key)
   at Allure.Net.Commons.Storage.AllureStorage.Get[T](String uuid)
   at Allure.Net.Commons.AllureLifecycle.AddAttachment(String name, String type, Byte[] content, String fileExtension)
   at NUnit.Allure.Core.AllureNUnitHelper.AddConsoleOutputAttachment()
   at NUnit.Allure.Core.AllureNUnitHelper.StopTestCase()
   at NUnit.Allure.Core.AllureNUnitAttribute.AfterTest(ITest test)
   at NUnit.Framework.Internal.Commands.TestActionCommand.<>c__DisplayClass0_0.<.ctor>b__1(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeAndAfterTestCommand.<>c__DisplayClass1_0.<Execute>b__1()
   at NUnit.Framework.Internal.Commands.DelegatingTestCommand.RunTestMethodInThreadAbortSafeZone(TestExecutionContext context, Action action)

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

Run Test1()

[SetUpFixture]
[AllureNUnit]
public class Setup
{

    [OneTimeSetUp]
    public void Setup1()
    {
        Console.Out.WriteLine("setup");
    }
}

[TestFixture]
[AllureNUnit]
public class Test :Setup
{
    
    [Test]
    public void Test1()
    {
        Console.Out.WriteLine("Test1");
    }
}

OR

[TestFixture]
[AllureNUnit]
public class Setup
{

    [OneTimeSetUp]
    public void Setup1()
    {
        Console.Out.WriteLine("setup");
    }
}

[TestFixture]
[AllureNUnit]
public class Test :Setup
{
    
    [Test]
    public void Test1()
    {
        Console.Out.WriteLine("Test1");
    }
}

What is the expected behavior?

Tests should work and Setup/Teardown methods should be logged accordingly in the report.
NUnit.Allure 1.2.1.1 handles this correctly logging a message.

What is the motivation / use case for changing the behavior?

Without the [AllureNunit] attribute added to setup classes they are not captured correctly in the report.
Check differences here

Please tell us about your environment:

  • Test framework: Nunit 3.13.3
  • Allure adaptor: Allure.Nunit 2.9.4-preview.2
  • Generate report using: Allure.Nunit 2.9.4-preview.2

Other information

This is related to #286
I suspect this has something to do with the deprecation of wrapIntoStep property or changes to wrapIntoStep method. Allure.Nunit 2.9.1-preview.5 does not have this problem

@vladdex
Copy link
Author

vladdex commented Mar 1, 2023

Hey guys, is anyone looking into this problem ?

@delatrie
Copy link
Contributor

Hi, @vladdex !

Try to remove [AllureNUnit] from setup fixtures and base classes:

[SetUpFixture]
public class Setup
{

    [OneTimeSetUp]
    public void Setup1()
    {
        Console.Out.WriteLine("setup");
    }
}

[TestFixture]
[AllureNUnit]
public class Test :Setup
{
    
    [Test]
    public void Test1()
    {
        Console.Out.WriteLine("Test1");
    }
}

OR

[TestFixture]
public class Setup
{

    [OneTimeSetUp]
    public void Setup1()
    {
        Console.Out.WriteLine("setup");
    }
}

[TestFixture]
[AllureNUnit]
public class Test :Setup
{
    
    [Test]
    public void Test1()
    {
        Console.Out.WriteLine("Test1");
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants