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

ArgumentOutOfRangeException thrown by Allure.NUnit if a test doesn't have a namespace #375

Closed
1 of 3 tasks
delatrie opened this issue Aug 9, 2023 · 0 comments · Fixed by #380
Closed
1 of 3 tasks
Assignees

Comments

@delatrie
Copy link
Contributor

delatrie commented Aug 9, 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?

Allure.NUnit throws an exception if no namespace is defined for a test.

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

Given the following test:

using NUnit.Allure.Core;
using NUnit.Framework;

[AllureNUnit]
class MyTestFixture
{
    [Test]
    public void MyTest() { }
}

When we run it, Allure.NUnit throws ArgumentOutOfRangeException with the message "Length cannot be less than zero.".

What is the expected behavior?

No exception is thrown. The report successfully generated.

Please tell us about your environment:

  • Allure version: 2.23.0
  • Test framework: nunit@3.13.3
  • Allure adaptor: allure-nunit@2.9.5-preview.1

Other information

The exception is thrown because of the following code:

Label.Package(_test.ClassName?.Substring(0, _test.ClassName.LastIndexOf('.'))),
Label.TestMethod(_test.MethodName),
Label.TestClass(_test.ClassName?.Substring(_test.ClassName.LastIndexOf('.') + 1))

Here LastIndexOf may return -1 in case there is no '.' in a class name leading to the exception in the Substring method. The only case there is no '.' symbol in the full name of a class is when the class doesn't have a namespace.

@delatrie delatrie self-assigned this Aug 9, 2023
delatrie added a commit that referenced this issue Sep 15, 2023
…and #375) (#380)

* Fix inconsistent one-time fixtures behavior (fixes #374)

* Fix crash when running test from empty namespace (fixes #375)

* Fix indentation for AllureAsyncOneTimeSetUoTests.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant