Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 00:32
    stevenaw commented #3829
  • Apr 20 22:52
    mikkelbu commented #3685
  • Apr 20 21:53
    mikkelbu milestoned #3386
  • Apr 20 21:53
    mikkelbu closed #3386
  • Apr 20 21:53
    mikkelbu commented #3386
  • Apr 20 21:44
    mikkelbu commented #2280
  • Apr 20 21:35
    mikkelbu commented #2799
  • Apr 20 21:29
    mikkelbu commented #2799
  • Apr 20 19:15
    dmitry-lipetsk commented #3786
  • Apr 20 18:46
    pakrym commented #3786
  • Apr 20 18:17
    CharliePoole commented #938
  • Apr 20 17:37
    Build #7101 passed
  • Apr 20 17:34
    rprouse commented #3786
  • Apr 20 17:33

    rprouse on master

    pakrym/optimize-or-filter Complete implementation and tes… optimize Pass counting and work… and 5 more (compare)

  • Apr 20 17:33

    rprouse on port-or-filter-to-master

    (compare)

  • Apr 20 17:33
    rprouse closed #3828
  • Apr 20 17:33
    rprouse commented #3786
  • Apr 20 16:22
    siprbaum commented #2799
  • Apr 20 16:12
    sixeyes opened #938
  • Apr 20 16:02
    pakrym commented #3786
shack05
@shack05
You can also try grouping just by 'traits' which will group by NUnit test categories. If you aren't using test categories it may give you the outcome you want but I'm not sure because i use categories
Terje Sandstrom
@OsirisTerje
@darrenge @shack05 is correct. The namespace part comes from how the Test Explorer interprets the "fully qualified name" it receives. The testname is just the last part, which you can modify, but the FQN not.
darrenge
@darrenge
Thanks for getting back to me. Shoot. We use the Group By with test categories but this is all part of the actual name and not the groupings. One of the response that confused me "the DefaultTestNamePattern is changing how the NUnit test adapter reports test names to the vstest platform (and therefore will change how they are shown in the test explorer window)". From the sounds of that statement, I should be able to change the DeafultTestNamePattern and just show the method name and not the fully qualified name. If you are curious on the code, it is all in Github at https://github.com/microsoft/FASTER/tree/master/cs/test
Terje Sandstrom
@OsirisTerje
image.png
Terje Sandstrom
@OsirisTerje
image.png
@darrenge The TestExplorer is responsible for the groupings marked in yellow above. The adapter/framework is responsible for the names in the red blocks above. The adapter can not change the way teh testexplorer handles its groups, since that is based on the FQN. What is coming in the red boxes however we can, and that is controlled by two properties in the runsettings. The one you refer to, which is sent down to the framework, and controls how the display name is reported. The term "display name" is a bit misleading, since it is really the Test Name that is changed, or even more precise, the Name of the Test. If we look at the output from the framework it comes in two steps, the discovery gives us the full information, which for a parametrized test looks like: ````<test-case id='0-1004' name='ThatMethodsAlsoWorks(42,True)' fullname='WrapThat.Tests.Answers.ThatMethodsAlsoWorks(42,True)' methodname='ThatMethodsAlsoWorks' classname='WrapThat.Tests.Answers' runstate='Runnable' seed='1730380949' />
where you see the name property and the fullname property, the latter being the same as the FQN in the Test Explorer. The last adapter property is the DisplayName setting, which can be either Name or FullName, and if you try to switch this to FullName you will see it affects ONLY the names used in the red boxes above. Changing the DefaultTestNamePattern as you did, will only change the displayname to contain the method and not the parameters, so it will look like the screenshot aboce, with multiple results shown for the parametrized test:
darrenge
@darrenge
Thanks @OsirisTerje ... yes, I am looking at changing the "yellow boxed" part. I like how the red boxed part works but just the overall grouping is what I want shortened. I will pursue Test Explorer folks on this one now. Thanks for your time on this.
Terje Sandstrom
@OsirisTerje
@darrenge Nice! If you get anything useful out there, please ping back with that. We're also interested in what more we can do with the Test Explorer, or simply opening up new possibilities.
Johan Eriksson
@johan-eriksson
image.png
Does anyone know a way to see which category the currently running TestFixture has?
Mikkel Nylander Bundgaard
@mikkelbu
@johan-eriksson Currently, that is not possible from within the test. However, you can access this from OneTimeSetUp or OneTimeTearDown, see e.g. nunit/docs#286 or nunit/nunit#2674
Paurush M Taunk
@paurushtaunk
Is there a way to make Nunit console runner read the TestResults.xml file and make it read the failed test names and then re-run them ?
Terje Sandstrom
@OsirisTerje
Considering removing support for legacy csproj format in the #NUnitTestAdapter version 4. Join the discussion https://github.com/nunit/nunit3-vs-adapter/discussions/816 if you have opinions on this
Timon
@TimonPost
I fire up a test runner but it locks a complete directory and doesn't release this until the whole application closes.
image.png

I call:

runner.StopRun();
runner.Unload();
runner.Dispose();
engine.Dispose();

In order to try force let this test runner release close the other processes.

However, they remain open.
How can I make sure that all processes related to the test runners are closed.
Timon
@TimonPost
 static void Main(string[] args)
        {
            // Get an interface to the engine
            using (ITestEngine engine = TestEngineActivator.CreateInstance())
            {
                // Create a simple test package - one assembly, no special settings
                TestPackage package = new TestPackage(@"E:\programming\FaultifyNew\Faultify\Benchmark\Faultify.Benchmark.NUnit\bin\Debug\netcoreapp3.1\test-duplication-0\Faultify.Benchmark.NUnit.dll");

                // Get a runner for the test package
                using (ITestRunner runner = engine.GetRunner(package))
                {
                    // Run all the tests in the assembly
                    XmlNode testResult = runner.Run(null, TestFilter.Empty);

                    runner.StopRun(true);
                    runner.Unload();
                }
            };
        }
Tanner Gooding
@tannergooding

What's the correct way to restrict a test to only running on Windows?

I thought it was Platform, but doing [Platform("Win")], for example, fails on .NET 5 with System.ArgumentException: Unknown framework version 5.5 (Parameter 'version') (followed by the stack trace)

Mikkel Nylander Bundgaard
@mikkelbu
@tannergooding [Platform("Win")] sounds correct, but the error sounds like you are using an older version of NUnit - before version 3.13 - see e.g. nunit/nunit#3565 for some more information
Eugene Krapivin
@EugeneKrapivin

Hey all, I looking for some help. I'm using

<PackageVersion Include="NUnit" Version="3.13.1" />
    <PackageVersion Include="NUnit.Analyzers" Version="3.0.0" />
    <PackageVersion Include="NUnit3TestAdapter" Version="3.17.0" />
    <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />

When I run dotnet test in my the root folder of my solution, my tests are found and run successfully:

D:\dvlp\cdp\MyProductionProject [develop ≡ +0 ~1 -0 !]> dotnet test
  Determining projects to restore...
  Restored D:\dvlp\cdp\MyProductionProject\src\MyProductionProject\MyProductionProject.csproj (in 1.82 sec).
  Restored D:\dvlp\cdp\MyProductionProject\tests\MyProductionProject.Unittests\MyProductionProject.UnitTests.csproj (in 1.82 sec).
  Restored D:\dvlp\cdp\MyProductionProject\tests\MyProductionProject.Functionaltests\MyProductionProject.Functionaltests.csproj (in 1.82 sec).
  2 of 5 projects are up-to-date for restore.
  MyProductionProject.Interface -> D:\dvlp\cdp\MyProductionProject\src\MyProductionProject.Interface\bin\Debug\netstandard2.0\MyProductionProject.Interface.dll
  MyProductionProject.Core -> D:\dvlp\cdp\MyProductionProject\src\MyProductionProject.Core\bin\Debug\netstandard2.0\MyProductionProject.Core.dll
  MyProductionProject.UnitTests -> D:\dvlp\cdp\MyProductionProject\tests\MyProductionProject.Unittests\bin\Debug\net472\MyProductionProject.UnitTests.dll
Test run for D:\dvlp\cdp\MyProductionProject\tests\MyProductionProject.Unittests\bin\Debug\net472\MyProductionProject.UnitTests.dll (.NETFramework,Version=v4.7.2)
  MyProductionProject -> D:\dvlp\cdp\MyProductionProject\src\MyProductionProject\bin\Debug\net472\MyProductionProject.exe
Microsoft (R) Test Execution Command Line Tool Version 16.8.3
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern. 
  MyProductionProject.Functionaltests -> D:\dvlp\cdp\MyProductionProject\tests\MyProductionProject.Functionaltests\bin\Debug\net472\MyProductionProject.Functionaltests.dll
Test run for D:\dvlp\cdp\MyProductionProject\tests\MyProductionProject.Functionaltests\bin\Debug\net472\MyProductionProject.Functionaltests.dll (.NETFramework,Version=v4.7.2)
Microsoft (R) Test Execution Command Line Tool Version 16.8.3
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:    36, Skipped:     0, Total:    36, Duration: 869 ms - MyProductionProject.UnitTests.dll (net472)

Passed!  - Failed:     0, Passed:    12, Skipped:     0, Total:    12, Duration: 16 s - MyProductionProject.Functionaltests.dll (net472)

however, trying to run the tests project at a time doesn't work

D:\dvlp\cdp\MyProductionProject [develop ↑2]> dotnet test Tests\MyProductionProject.UnitTests\MyProductionProject.UnitTests.csproj --no-build
Test run for D:\dvlp\cdp\MyProductionProject\Tests\MyProductionProject.UnitTests\bin\net472\MyProductionProject.UnitTests.dll (.NETFramework,Version=v4.7.2)
Microsoft (R) Test Execution Command Line Tool Version 16.8.3
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
No test is available in D:\dvlp\cdp\MyProductionProject\Tests\MyProductionProject.UnitTests\bin\net472\MyProductionProject.UnitTests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

Additionally, path to test adapters can be specified using /TestAdapterPath command. Example  /TestAdapterPath:<pathToCustomAdapters>.

any ideas? i'm stuck with this crap for a day now, probably something dumb i'm missing

Terje Sandstrom
@OsirisTerje
Hmm..... why is the paths to the dll's different ? (bin\Debug\net472 versus bin\net472 -- do both have the adapter there ?
Eugene Krapivin
@EugeneKrapivin
its my bad I actually ran then with different build switches, but the result is the same really
Terje Sandstrom
@OsirisTerje
What happens if you go down to the bin directory and run the test dll there ? Also, there are an daapter in that directory?
Eugene Krapivin
@EugeneKrapivin
yeah all is there
Terje Sandstrom
@OsirisTerje
well, then it doesnt make sense. Can you create a small repro and upload ?
Eugene Krapivin
@EugeneKrapivin
i've done a clean build in release, ran only one test project, ran all test projects under the solution - worked
Terje Sandstrom
@OsirisTerje
you mean ti works now ?
Eugene Krapivin
@EugeneKrapivin
only if I run all tests under the solution
if i run a specific test project it doesn't run... which make me mad, cuz the CI is running the test projects 1 by 1, while I run them all together on my machine :D
Terje Sandstrom
@OsirisTerje
ok, it should work for single runs, it should work for running the csprojs, and for running the dlls directly
so there is something missing
if you create a new test project using dotnet new unit, and then try to run that, does that work ?
Eugene Krapivin
@EugeneKrapivin
gimme a sec I'll try to create a repro... i'm sure its something stupid that I'll have to look for days now
https://pastebin.com/jAYY8jym there is a trace here from my build and both test runs... its a bit long I preferred to paste it outside so to not spam
Eugene Krapivin
@EugeneKrapivin
ok it seems like i've found it. once i began looking at the paths side by side i found that the dotnet test on the solution will generate paths with different cases, based on the paths in the sln file. which would work... for some reason, targeting the csproj directly (like our CI) would do wasn't working well, probably because the build paths and dll names were a bit different
Eugene Krapivin
@EugeneKrapivin
alas im failing to reproduce
Zoroark
@utybo
Hello! Is there any way of doing the following cleanly? I want to add multiple constraints on some Property(), but I'm not sure on how to do that. My apologies if this isn't the right place for asking this...
class Two
{
    public string C { get; set; }
    public string D { get; set; }
}

class One
{
    public string A { get; set; }
    public Two B { get; set; }
}

[Test]
public void MyTest()
{
    // Imagine that this is returned by some function
    var result = new One {A = "a", B = new Two {C = "c", D = "d"}};

    Assert.That(result, Has.Property("A").EqualTo("a")
        // Constraints on result.B.*
        .And.Property("B").Property("C").EqualTo("c")
        .And.Property("B").Property("D").EqualTo("d"));
}
Tanner Gooding
@tannergooding
Is there a way to mark an abstract or virtual method as a [Test]?
From what I'm seeing locally, I have to redeclare the attributes on the concrete implementations in the derived type.
Joseph Musser
@jnm2
@tannergooding I don't see why we couldn't implement that. I'm not sure it's been directly considered.
One existing way to do this is to make the test method nonvirtual in the base class and have it call derived impls.
1 reply
@utybo Constraint syntax doesn't really let you form a tree structure like that. I'd use two assert statements.
3 replies
Test Name
@SomePersonOnline_gitlab
Hi I have some non-test code that creates an AppDomain and loads a class, it never references NUnit in any way. Now I am testing this code using NUnit and somehow when I create the very same class from the very same non-testcode binary it wants to load NUnit.Framework on that AppDomain. Does NUnit 'inject' itself in someway in an AppDomain, if so, why? This is causing issues now as it cannot find the binary and I don't want 'load NUnit.Framework' code in non-test code. Is there a way around this that it doesn't do that for certain domains?
2 replies
Bernd Baumanns
@bernd5
Hello together
Currently I use NUnit with VS Adapter in Visual studio - with about 10k tests which works quite nice
I only some way to categorize errors
Is there some way to group by exception?
no executed / pass and fail seem to be insufficient