Thanks to visit codestin.com
Credit goes to github.com

Skip to content

NUnitLite fails with ArgumentException in AOT publish #4987

@vpenades

Description

@vpenades

using NUnit 4.3.2 and NUnitLite 4.3.2 , I am trying to create a console test that is run like this:

class Program
{
    static int Main(string[] args)
    {
        return new AutoRun(typeof(CustomTests).Assembly).Execute(args);   
    }
}

When I run the program in normal mode, the tests run just fine, but when I publish the console application and I try to run it, I get this output:

Runtime Environment
   OS Version: Microsoft Windows 10.0.19045
  CLR Version: 8.0.16

Test Files


System.ArgumentException: Argument name must not be the empty string (Parameter 'name')
   at NUnit.Framework.Guard.<ArgumentNotNullOrEmpty>g__ThrowArgumentNotNullOrEmpty|1_0(String) + 0x44
   at NUnit.Framework.Internal.Test..ctor(String, String, ITypeInfo, IMethodInfo) + 0x23
   at NUnit.Framework.Internal.TestSuite..ctor(String) + 0x53
   at NUnit.Framework.Internal.TestAssembly..ctor(String) + 0x17
   at NUnit.Framework.Api.DefaultTestAssemblyBuilder.Build(Assembly, String, IDictionary`2) + 0x500
   at NUnit.Framework.Api.NUnitTestAssemblyRunner.Load(Assembly, IDictionary`2) + 0xc8
   at NUnitLite.TextRunner.LoadTests(IDictionary`2) + 0x36
   at NUnitLite.TextRunner.Execute() + 0x359

After some investigation, I've found that publishing with:

<PropertyGroup>		
	<RuntimeIdentifier>win-x64</RuntimeIdentifier>
	<PublishAot>true</PublishAot>
</PropertyGroup>

Fails, but publishing with:

<PropertyGroup>		
	<RuntimeIdentifier>win-x64</RuntimeIdentifier>
	<PublishTrimmed>true</PublishTrimmed>
	<SelfContained>true</SelfContained>	
</PropertyGroup>

Succeeds.

The whole point of the tests I'm doing is to pick trimming issues, so with the trimming might be enough, but I don't see why PublishAot should not work either.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions