nunit

NUNIT + VS2010 = Unable to copy file from /obj to /bin…being used by another process

别等时光非礼了梦想. 提交于 2019-12-10 17:13:22
问题 I am trying to run some unit tests using NUnit while I have the project open, and VS 2010 cannot rebuild the project while the assembly is loaded in NUnit. I have looked around and haven't found any solutions that seen to fix it. I can close NUnit, then the project builds fine. This is a the same solution based on Rob Conery's BDD demo found here: http://tekpub.com/view/concepts/5 Any thoughts? 回答1: Turn ON the windows process "Volume Shadow Copy" as specified in this question. The question

NUnit best practice

a 夏天 提交于 2019-12-10 16:36:07
问题 Environment: (C# WinForms application in Visual Studio Professional 2008) I've been digging around a little for guidance on NUnit best practices. As a solo programmer working in a relatively isolated environment I'm hoping that collective wisdom here can help me. Scott White has a few good starting points here but I'm not sure I totally agree with everything he's said -- particularly point 2. My instincts tell me that the closer a test is to the code being tested the more likely you are to

NHibernate SchemaExport not creating table

好久不见. 提交于 2019-12-10 16:34:25
问题 I'm learning Nhibernate and am making a test project. I want to generate tables based on the entities. In the test project, I am using sqlite and can see the output: "drop table if exists Player" but it's not creating the table Player afterwards. I have confirmed by copying the Player.hbm.xml file into another folder that the mapping is being found. Test class in the test project: [Test] public void TestCanGenerateSchema() { var cfg = new Configuration(); cfg.Configure(); //tell NH to

NUnit secondary thread exception

杀马特。学长 韩版系。学妹 提交于 2019-12-10 16:19:25
问题 I'm testing the code which starts a secondary thread. And this thread sometimes throws an exception. I'd like to write a test which fails if that exception isn't handled properly. I've prepared that test, and what I'm seeing in NUnit is: LegacyImportWrapperTests.Import_ExceptionInImport_Ok : PassedSystem.ArgumentException: aaaaaaaaaa at Import.Legacy.Tests.Stub.ImportStub.Import() in ImportStub.cs: line 51... But the test is marked as GREEN. So, NUnit knows about that exception, but why does

Very long build time in Visual Studio

霸气de小男生 提交于 2019-12-10 15:57:37
问题 I've a solution with 15 projects (14 class libraries and one web application). Each class library has corresponding test project (i.e. if I have MyApp.Services project there exists MyApp.Services.Tests -- using NUnit). Everything is written in VB.NET. The problem is that when VS tries to compile any of *.Tests project it stops responding (the bigger the project the longer the period without reposnse). I don't know where to start looking for an issue. I'll add that I've R# 4.5 installed.

C# Assert.AreNotEqual versus Equals

醉酒当歌 提交于 2019-12-10 15:37:41
问题 While trying to verify to myself, that C# Equals for IEnumerables is a reference equals, I found something odd. With the following setup in NUnit var a = (IEnumerable<string>)(new[] { "one", "two" }); var b = (IEnumerable<string>)(new[] { "one", "two" }); this test Assert.IsFalse(a.Equals(b)); passes, while this test Assert.AreNotEqual(a, b); doesn't. Can anybody explain why? Edit: Thanks for the answers. I just read the documentation for NUnit, and it says the same thing, that AreEqual and

.NET test framework with parameterized unit testing, that shows red/green for each combination?

荒凉一梦 提交于 2019-12-10 13:57:06
问题 Parameterized Unit Testing is great when you have X unit test * Y configurations. I have 3 unit tests, and each must run in 5 particular situations. I use xUnit.net's Theory / PropertyData feature, it works well. PROBLEM: In the Test Runner UI, there is one green/red symbol per unit test, which means 3 . It makes it difficult to evaluate progress: the symbol is red until ALL configurations work perfectly. I want 15 symbols, one per unit test * configuration, to know what particular

Mock File IO static class in c#

一笑奈何 提交于 2019-12-10 13:29:42
问题 I am new to Unit Testing, and I need to mock the File static class in System.IO namespace. I am using Rhinomock, what is the best way to accomplish this, Lets say I need to mock the File.Exists,File.Delete ... 回答1: You can't mock static methods with Rhino mock. See this question for more info. You could create a facade class to wrap the file system calls you will use and then create a mock version of that. 回答2: You should create a wrapper service called IFileService, then you can create a

Is it possible to customize NUnit XML Output

给你一囗甜甜゛ 提交于 2019-12-10 13:28:25
问题 I'm looking at NUnit XML output right now, and wonder if it's possible to generate the output for failures only . I mean, if a test passes ok, no XML output gets generated for it at all. ( UPDATE : XSLT is not an option here. I don't want XML output for passed tests at all : if I don't need the details about the passed tests, I don't want the system to spend time generating those details.) The idea is, XML output tend to be quite large if you have a lot of tests, but 80% of the time you're

NUnit TestCaseSource pass value to factory

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 13:16:51
问题 I'm using the NUnit 2.5.3 TestCaseSource attribute and creating a factory to generate my tests. Something like this: [Test, TestCaseSource(typeof(TestCaseFactories), "VariableString")] public void Does_Pass_Standard_Description_Tests(string text) { Item obj = new Item(); obj.Description = text; } My source is this: public static IEnumerable<TestCaseData> VariableString { get { yield return new TestCaseData(string.Empty).Throws(typeof(PreconditionException)) .SetName("Does_Reject_Empty_Text");