Skip to content

NullReferenceException when null arguments are used in TestFixtureAttribute #1934

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

Closed
sir-wilhelm opened this issue Dec 21, 2016 · 4 comments · Fixed by #2041
Closed

NullReferenceException when null arguments are used in TestFixtureAttribute #1934

sir-wilhelm opened this issue Dec 21, 2016 · 4 comments · Fixed by #2041
Assignees
Milestone

Comments

@sir-wilhelm
Copy link

This seems to be related to #1507. We started getting several errors after moving from 3.4 to 3.5. The errors can be seen in the Visual Studio test runner and the nunit3-console runner. The errors are all similar to the following:

1) Invalid : Tests.Controls.iBus.When_the_passed_in_domain_is_null
An exception was thrown while loading the test.
System.NullReferenceException: Object reference not set to an instance of an object.
   at NUnit.Framework.Internal.Builders.DefaultSuiteBuilder.HasArguments(IFixtureBuilder attr)
   at NUnit.Framework.Internal.Builders.DefaultSuiteBuilder.GetFixtureBuilderAttributes(ITypeInfo typeInfo)
   at NUnit.Framework.Internal.Builders.DefaultSuiteBuilder.BuildFrom(ITypeInfo typeInfo)

This is one example of the test fixtures/constructors that are failing again:

[TestFixture(null)]
[TestFixture("")]
[TestFixture(" ")]
[TestFixture("\t")]
public class When_the_passed_in_domain_is_null : BasePresenterTest
{
    private readonly string _domain;

    public When_the_passed_in_domain_is_null(string domain)
    {
        _domain = domain;
    }
}
@gcichosz
Copy link
Contributor

gcichosz commented Feb 7, 2017

How a confirmation of that kind of issue should look like? I got similar results using console runner build from the newest sources. Is that enough to start working on this issue?

@ChrisMaddock
Copy link
Member

Yup - that's great @gcichosz. 😄

Issues are generally marked with [confirm] when they're first reported - if anyone else can repro them they're considered confirmed. It often makes a good triage-stage, which rules out some errors users report specific to their own machines machine/tests suites, and catches issues where there isn't enough information to reproduce the problem.

I've assigned you to this one. I'm not sure if you've already dug through the history, but looks like is a regression which may have been caused by #1508 - maybe worth a look at what went on there.

@gcichosz
Copy link
Contributor

gcichosz commented Feb 8, 2017

Sorry to ask, but how do I debug nunit.framework through nunit3-console? I tried copying nunit.framework.dll and starting nunit3-console as an external process, but that doesn't seem to work.

@ChrisMaddock
Copy link
Member

I normally find it easier to use the nunitlite-runner, rather than the nunit-console from debugging framework issues.

I do everything in the VS solution. First I add a test that hits the problem to nunit.framework.tests-2.0. Then I pass the path of the the nunit.framework.tests-2.0.dll as a command line argument to the nunitlite-runner-2.0 project, and set that as my startup project.

The nunit.framework.tests projects are built against the relative framework in the soultion, so doing that allows you to hit breakpoints in the framework. 😄

We should maybe write this up somewhere, not the console and framework are in different repositories.

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

Successfully merging a pull request may close this issue.

4 participants