Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 06:44
    mikkelbu commented #3880
  • Jun 20 22:07
    mikkelbu commented #3880
  • Jun 20 20:29
    stevenaw edited #3881
  • Jun 20 20:28
    stevenaw commented #3881
  • Jun 20 20:26
    stevenaw commented #3841
  • Jun 20 20:24
    Build #7147 passed
  • Jun 20 20:18
    stevenaw synchronize #3881
  • Jun 20 20:09
    mikkelbu edited #3880
  • Jun 20 19:41
    MichaelKetting commented #3841
  • Jun 20 13:17
    stevenaw commented #3881
  • Jun 20 13:04
    Build #7146 passed
  • Jun 20 13:01
    stevenaw edited #3881
  • Jun 20 12:59
    stevenaw opened #3881
  • Jun 20 02:14
    csanghavi edited #3880
  • Jun 20 01:44
    stevenaw assigned #3841
  • Jun 20 01:44
    stevenaw commented #3841
  • Jun 19 23:47
    csanghavi opened #3880
  • Jun 19 21:18
    Build #7145 passed
  • Jun 19 21:16
    mikkelbu labeled #3875
  • Jun 19 21:15
    mikkelbu milestoned #3875
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
Richard Fine
@richard-fine
Hello. I have a parametric fixture, and I want to use the parameter value to further generate parameters for a particular test within that fixture. Is this possible somehow? I have a feeling I would need to provide my own ITestBuilder, but I'm not sure if it's possible for me to access the fixture parameters from that point.
with the testcase source you are free to create what data you like...
Richard Fine
@richard-fine
TestCaseSource doesn't work because it has to be static
anyway, I found a solution - inside ITestBuilder, suite.Arguments actually does contain the parameters for my fixture, so I can use it to generate my test cases
Bernd Baumanns
@bernd5
👍
Nicolas Bourbaki
@b0urb4k1
Hidiho, what is the proper way to provide data to for tests? Until now i copied data outside of the tests in scripts, the problem is though that this makes working in Visual Studio a bit cumbersome. So i thought to do the copying in the tests now, this does not seem to work as intended though since the TestCaseSources are evaluated earlier than all the SetUp attributed Methods. Is there any way to make this work properly or should i try to find another solution?
Terje Sandstrom
@OsirisTerje
@b0urb4k1 Not sure what is the problem, first TestCaseSources evaluated before SetUp - not really, but you probably have something static there, anyway, it should not affect your tests. Whether you have your test data in seperate files or included with the source code, should not matter. You can look at the test project and the acceptance test project in the adapter for one way of doing it. It could also help if you could show some code to exemplify what is your problem, easier for us to help too :-)
Nicolas Bourbaki
@b0urb4k1
What i want to do is to copy some files that are used to build the TestCaseSources. The TestCaseSource iterates and searches for files that should previously been copied. I read somewhere that the TestCases are used to build the actually run tests before the setup methods are called, which would explain the behaviour i see, that is am empty folder. So what i did now is to copy the files in the static property's get method, which works but is of course kind of sucky.
Terje Sandstrom
@OsirisTerje
You can use a OneTimeSetup attributed method to do that, if all your tests are in the same test class. If they are over m,ultiple classes, you can use a SetupFixture for the same purpose, and place that at global level, so that it is at assembly level. It will run before any tests are executed. See details here: https://docs.nunit.org/articles/nunit/writing-tests/attributes/setupfixture.html
Nicolas Bourbaki
@b0urb4k1
What i would do now if there is no proper way to do it in code is that i will write a small Func that combines copying the files and returning the enumeration.
Well at least the OneTimeSetup on the actual test did not work, that is what i had.
I will check if it works with the fixture though tomorrow.
Still now 100% ideal, since this also would copy data that is not used if you run it from the VS Test Explorer. With a single test that is.
Terje Sandstrom
@OsirisTerje
Cool.... if the OneTimeSetup didnt work, there is something you do in the file loading - but anyway , the setupfixture should do it for you. TestCaseSources are statics, so they can fool you if you access them too early. They should be doing things in a lazy manner, not in the ctor.
Nicolas Bourbaki
@b0urb4k1
I also might try to use the proposed static constructor.
Oh now that is nifty :) i also could do the lazy thing and just copy the file when the test gets instanciated ... :)
Nicolas Bourbaki
@b0urb4k1
I kind of love that idea, so i will either use the static constructor for simplicity or the solution to enumerate the files from the server and use the lazy solution to copy them and return the local file path.
Nicolas Bourbaki
@b0urb4k1
The code i wrote to sync the server and local directory is split up in yielding commands that need to be executed in order to do the sync and an interpreter, so i think i should be able to enumerate the query in the TestCaseSource and wrap them in a Func with the deleted files calling Assert.Ignore