nunit

NUnit SetUpFixture attribute equivalent in xUnit?

余生颓废 提交于 2021-02-07 03:18:28
问题 In nUnit, SetUpFixture allowed me to run some code before any tests. Is there anything like that when using xUnit? From nUnit documentation: This is the attribute that marks a class that contains the one-time setup or teardown methods for all the test fixtures under a given namespace. 回答1: xUnit's comparison table shows that where you would use [TestFixtureSetUp] in NUnit, you make your test fixture class implement IUseFixture<T> . If [TestFixtureSetUp] isn't the attribute you're looking for,

How do I install NUnit 3 console on Windows and run tests?

拜拜、爱过 提交于 2021-02-05 20:18:36
问题 I want to run tests from a console like this (being in any directory, the DLL file can be for a different .NET version): $ nunit3-console test.dll I googled a lot, but can't find how to set up this. The official tutorial has nothing useful and is complete zero. Following it gets me nowhere: https://github.com/nunit/docs/wiki/Installation 回答1: It is hard to find, because there is a lot of outdated documentation, either for NUnit2 or NUnit3. Steps: Official NUnit3 console installers are here:

How do I install NUnit 3 console on Windows and run tests?

喜你入骨 提交于 2021-02-05 20:17:50
问题 I want to run tests from a console like this (being in any directory, the DLL file can be for a different .NET version): $ nunit3-console test.dll I googled a lot, but can't find how to set up this. The official tutorial has nothing useful and is complete zero. Following it gets me nowhere: https://github.com/nunit/docs/wiki/Installation 回答1: It is hard to find, because there is a lot of outdated documentation, either for NUnit2 or NUnit3. Steps: Official NUnit3 console installers are here:

NUnit's CollectionAssert return false for similar lists of custom class

孤者浪人 提交于 2021-02-05 06:33:40
问题 Here is my class: public class MyClass { public string Name { get; set; } public string FaminlyName { get; set; } public int Phone { get; set; } } Then I have two similar list: List<MyClass> list1 = new List<MyClass>() { new MyClass() {FaminlyName = "Smith", Name = "Arya", Phone = 0123}, new MyClass() {FaminlyName = "Jahani", Name = "Shad", Phone = 0123} }; List<MyClass> list2 = new List<MyClass>() { new MyClass() {FaminlyName = "Smith", Name = "Arya", Phone = 0123}, new MyClass()

Debug nunit tests in a Linux docker container from Visual Studio

有些话、适合烂在心里 提交于 2021-01-28 16:33:31
问题 I'm trying to change our .NET Core 3.0 app to run in a Linux container. I've gotten to the point where I can restore and build within the container but the tests are failing, which is expected. There are certain things within the app that were only meant for Windows machines. I want to debug the tests within the container from Visual Studio on Windows and haven't been able to do this yet. From what I've read, there doesn't seem to be a way to debug the test from running dotnet test. There

Debug nunit tests in a Linux docker container from Visual Studio

僤鯓⒐⒋嵵緔 提交于 2021-01-28 16:31:44
问题 I'm trying to change our .NET Core 3.0 app to run in a Linux container. I've gotten to the point where I can restore and build within the container but the tests are failing, which is expected. There are certain things within the app that were only meant for Windows machines. I want to debug the tests within the container from Visual Studio on Windows and haven't been able to do this yet. From what I've read, there doesn't seem to be a way to debug the test from running dotnet test. There

Debug nunit tests in a Linux docker container from Visual Studio

北战南征 提交于 2021-01-28 16:31:15
问题 I'm trying to change our .NET Core 3.0 app to run in a Linux container. I've gotten to the point where I can restore and build within the container but the tests are failing, which is expected. There are certain things within the app that were only meant for Windows machines. I want to debug the tests within the container from Visual Studio on Windows and haven't been able to do this yet. From what I've read, there doesn't seem to be a way to debug the test from running dotnet test. There

How to get all text from console to string?

*爱你&永不变心* 提交于 2021-01-28 01:07:00
问题 I do test in that way: NUnit.ConsoleRunner.Runner.Main(new string[] { System.Reflection.Assembly.GetExecutingAssembly().Location,"OpenShop_Firefox.dll", }); And i want to get all text from console to one string. What is the best way? 回答1: You need to set Console.Out to a stream of your choosing: using (StringWriter stringWriter = new StringWriter()) { Console.SetOut(stringWriter); NUnit.ConsoleRunner.Runner.Main(new string[] { System.Reflection.Assembly.GetExecutingAssembly().Location,

How to configure Teamcity to ignore some tests

℡╲_俬逩灬. 提交于 2021-01-27 03:58:59
问题 There is a way to configure Teamcity to ignore some tests? I need to run these tests only locally, when they are running in Teamcity, must be ignored. I'm using nunit. This could be a directive, attribute, etc. 回答1: You can do this by adding test categories to your tests. [Category("LocalOnly")] [Test] public void MyLocalTest() { // Code omitted for brevity } You can then add that category to the NUnit runner's 'NUnit categories exclude:' field in the TeamCity build step. NUnit categories

How to configure Teamcity to ignore some tests

橙三吉。 提交于 2021-01-27 03:58:24
问题 There is a way to configure Teamcity to ignore some tests? I need to run these tests only locally, when they are running in Teamcity, must be ignored. I'm using nunit. This could be a directive, attribute, etc. 回答1: You can do this by adding test categories to your tests. [Category("LocalOnly")] [Test] public void MyLocalTest() { // Code omitted for brevity } You can then add that category to the NUnit runner's 'NUnit categories exclude:' field in the TeamCity build step. NUnit categories