nunit

FsUnit `should equal` fails on `Some []`

て烟熏妆下的殇ゞ 提交于 2019-12-31 00:55:07
问题 When I run this FsUnit test with NUnit 2.6.3, let f xs = Some (List.map ((+) 2) xs) [<Test>] let test() = f [] |> should equal (Some []) I get: Result Message: Expected: <Some([])> But was: <Some([])> Result StackTrace: at FsUnit.TopLevelOperators.should[a,a](FSharpFunc`2 f, a x, Object y) The test fails even though the Expected and Actual in the message are the same. What happened? 回答1: The reason is that FsUnit uses untyped mechanism under the hood so Expected is inferred as object by the

nUnit Exception on a 64 bit Machine

僤鯓⒐⒋嵵緔 提交于 2019-12-30 17:59:13
问题 I have an MVC 3.0 app. My testing framework is nUnit 2.4.8.0. I started this code on a 32 bit machine, and recently started using a 64 bit machine. I just as recently upgraded the project to .NET 4.0. My application runs fine - I am able to hydrate my objects from the database appropriately. The issue is when I run my integration tests. The tests fail, and give an exception I've never seen before: NHibernate.ADOException : cannot open connection ----> System.BadImageFormatException : An

Prevent Visual Studio from breaking on unhandled exceptions

三世轮回 提交于 2019-12-30 17:27:10
问题 I have a set of NUnit tests (running using the Resharper test runner), and some of those fail due to assertion exceptions happening in background threads; and when this happens VS2017 breaks into the debugger, what is undesirable as I want it to keep on running other tests. All the settings in "Exception Settings/CLR/Thrown" are turned off. The "User-Unhandled" settings in that dialog aren't present whether I switch the "Just My Code" option on or off All the "Exception Settings/Managed

NUnit doesn't find tests in assembly

北城余情 提交于 2019-12-30 10:51:55
问题 I inherited an assembly with MSTest, but these tests were run using nunit-console on the build machine (not sure how it worked). So I decided to sort it out and change them to proper NUnit tests, but now nunit-console (or gui) can't find any tests. They run just fine using ReSharper test runner though. Any idea what could be missing? 回答1: Check: Is the class public? Does it have a public parameterless constructor (e.g. the default one if you don't specify any other constructors) Does it have

NUnit integration tests and dependency injection

风格不统一 提交于 2019-12-30 09:00:08
问题 I'm currently making use of Castle Windsor version 2.1 as my container and would like to perform integration tests using the services registered with it. Currently, I do this my using the Common Service Locator to retrieve my service instance and perform my integration tests against it as such: var myService = ServiceLocator.Current.GetInstance<IMyService>(); // do stuff with myService What I'd ideally like to do is have my service dependencies injected into my NUnit test fixture

NUnit integration tests and dependency injection

*爱你&永不变心* 提交于 2019-12-30 09:00:03
问题 I'm currently making use of Castle Windsor version 2.1 as my container and would like to perform integration tests using the services registered with it. Currently, I do this my using the Common Service Locator to retrieve my service instance and perform my integration tests against it as such: var myService = ServiceLocator.Current.GetInstance<IMyService>(); // do stuff with myService What I'd ideally like to do is have my service dependencies injected into my NUnit test fixture

Use NUnit Console Runner to run all tests under a folder

时光总嘲笑我的痴心妄想 提交于 2019-12-30 07:05:32
问题 I am trying to use NUnit Runners 2.6.4 to run all test assemblies in my test folder. My current command looks like this: /nologo /noshadow /framework:net-4.0 /xml:.\test\TestResults.xml .\test\*.Test.dll Unfortunately Nunit just throws a System.ArgumentException: Illegal characters in path. Is there anyway I can achieve this? 回答1: It's not possible to use the wildcards for the input files, but you can specify multiple test libraries in the command line: /nologo /noshadow /framework:net-4.0

Using MS Test ClassInitialize() and TestInitialize() in VS2010 as opposed to NUnit

不打扰是莪最后的温柔 提交于 2019-12-30 05:34:12
问题 I've used NUnit with VS2008, and now am adapting to MSTest on VS2010. I used to be able to create an object in TestSetup() and dispose of it in TestCleanup(), and have the object created each time a test method was run in NUnit, preventing me from duplicating the code in each test method. Is this not possible with MSTest? The examples I am finding using the ClassInitialize and ClassCleanup and TestInitialize and TestCleanup attributes only show how to write to the console. None show any more

Skip the SetUp method only for a particular test in NUnit?

自闭症网瘾萝莉.ら 提交于 2019-12-30 04:00:32
问题 I have a test where I do not need to run the SetUp method (attributed with [SetUp] ) before running the test. I need the SetUp method to be run for other tests. Is there a different attribute that can be used or a non-attribute-based way to achieve this? 回答1: You should create a new class for that test which has only the setup (or lack of setup) that it needs. Alternatively, you could unfactor the setup code into a method that all the other tests call, but I don't recommend this approach. 回答2

NUnit - Is it possible to check in the TearDown whether the test succeeded?

£可爱£侵袭症+ 提交于 2019-12-30 01:37:10
问题 I would like to have my TearDown method check whether the previous test was a success before it applies some logic. Is there an easy way to do this? 回答1: If you want to use TearDown to detect status of last test with NUnit 3.5 it should be: [TearDown] public void TearDown() { if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed) { //your code } } 回答2: This has been already solved in Ran's answer to similar SO question. Quoting Ran: Since version 2.5.7, NUnit allows