nunit

Fetch Params from Nunit3 in C# test fixture

こ雲淡風輕ζ 提交于 2020-01-15 06:44:43
问题 I am using the params argument provided in the Nunit3 version to pass multiple parameters. However, I am unable to fetch them with the C# test fixture. I have searched but unable to get a correct result. Can someone provide me with the pointers on how to fetch those param arguments in c#. Any help will be appreciated. Thanks in advance. 回答1: First, make sure that you are using both NUnit console 3.4.1 and NUnit Framework 3.4.1. Your command line option of --params:Code=XXX --params:Date=2011

NUnit.Runners via Nuget on Visual Studio 2012 express doesn't work

喜夏-厌秋 提交于 2020-01-14 08:20:23
问题 I'm trying to set up simple NUnit project in Visual Studio 2012 Express using NuGet manager. From PROJECT-> Manage NuGet Packages I installed NUnit (framework) and wanted add NUnit.Runner but during installation I'm receiving: 'NUnit.Runners 2.6.2' already installed. Ok, but when I go to the TOOLS->Library Package Manager->Manage nuGet Packages for Solution both NUnit (framework) and NUnit.Runners are displayed as installed. I can use NUnit framework in the code but when I'm trying to run

Why are tests taking longer to run in TeamCity than when run directly in NUnit?

核能气质少年 提交于 2020-01-14 07:36:10
问题 I have some C# performance tests, basically running two different methods and checking that one runs much faster than the other. When I run them locally in NUnit, one of the tests runs ten times as fast as the other, so I've got an NUnit test that uses Stopwatch to check that it is at least twice as fast (in case of regression). But when I run the tests in TeamCity, the fast method is only about 1.5 times as fast as the slow one? I would expect hardware differences to have some effect, but

How to use ITestEventListener in NUnit 3?

亡梦爱人 提交于 2020-01-14 02:07:24
问题 I want to add a custom test reporter to NUnit. I already did it with NUnit2, but I now need to use NUnit3. To implement the reporter, I need to get various events from the framework, like start, end and failure of tests. In NUnit2 I used NUnitHook to register my EventListener and it worked pretty good. In NUnit3 I need to use the extension point mechanism , but when I add the extension point to the project, VisualStudio (2012 ultimate) immediately fails to discover the NUnit tests.

How to use ITestEventListener in NUnit 3?

雨燕双飞 提交于 2020-01-14 02:07:09
问题 I want to add a custom test reporter to NUnit. I already did it with NUnit2, but I now need to use NUnit3. To implement the reporter, I need to get various events from the framework, like start, end and failure of tests. In NUnit2 I used NUnitHook to register my EventListener and it worked pretty good. In NUnit3 I need to use the extension point mechanism , but when I add the extension point to the project, VisualStudio (2012 ultimate) immediately fails to discover the NUnit tests.

How to run unit tests for Xamarin library projects (iOS and Android)?

假装没事ソ 提交于 2020-01-13 11:15:35
问题 I'm creating a component for the Xamarin Component Store, providing a Library for Android and iOS. I've put NUnit tests into both library projects but I can't run the unit tests. Is it possible to execute tests in a Android/iOS library project? 回答1: If you make your library a PCL, you can create a NUnit project that links to the PCL and run your tests that way: https://dzwonsemrish7.cloudfront.net/items/0H3W383D2e031q1p3s40/Screen%20Shot%202013-08-12%20at%207.56.05%20PM.png?v=d5aac873 Xamarin

How to run unit tests for Xamarin library projects (iOS and Android)?

那年仲夏 提交于 2020-01-13 11:13:45
问题 I'm creating a component for the Xamarin Component Store, providing a Library for Android and iOS. I've put NUnit tests into both library projects but I can't run the unit tests. Is it possible to execute tests in a Android/iOS library project? 回答1: If you make your library a PCL, you can create a NUnit project that links to the PCL and run your tests that way: https://dzwonsemrish7.cloudfront.net/items/0H3W383D2e031q1p3s40/Screen%20Shot%202013-08-12%20at%207.56.05%20PM.png?v=d5aac873 Xamarin

Mock Static class using moq

走远了吗. 提交于 2020-01-13 09:22:11
问题 I am writing unit test cases with the help of NUnit and have some static classes that I need to mock to run test cases so can we mock static class with the help of MOQ mocking framework? Please suggest If some have idea. 回答1: There are two ways to accomplish this - As PSGuy said you can create an Interface that your code can rely on, then implement a concrete that simply calls the static method or any other logging implementation like NLog. This is the ideal choice. In addition to this if you

Dependencies not flowing between dependent projects, causing System.IO.FileNotFoundException

半城伤御伤魂 提交于 2020-01-13 07:39:29
问题 Let's say my solution has 2 projects: The first called "MainProject" (A .NETStandard 2.0 project). The second called "MainProjectTests" (A NUnit test project) with some unit tests for each class into "MainProject". The first project (MainProject) has a NuGet dependency called "dependencyX". Obviously, the project "MainProjectTests" has a reference to "MainProject". So when the test runner runs a test of "MainProjectTests" that calls methods from "MainProject" using "dependencyX" I'm getting a

How to combine collection and property assertions using fluent-assertions?

梦想与她 提交于 2020-01-12 14:29:28
问题 I would like to "combine" Fluent Assertion's collection assertions and property assertions, e.g. assert that two IEnumerable 's are pairwise-equal using property-by-property (possibly "nested") comparison (i.e. structural equality, in functional language parlance). Concrete example: var dic = new Dictionary<int, string>() { {1, "hi"}, {2, "bye" } }; var actual = dic.ToSelectListItems(0).OrderBy(si => si.Text); var expected = new List<SelectListItem>() { new SelectListItem() {Selected = false,