nunit

Unit testing method converting MVC view to string using View.Render method

我怕爱的太早我们不能终老 提交于 2019-12-23 09:33:31
问题 I have written method that converts MVC view to string and test method to check if it returns string. Of course it works with Web but when I run test in NUnit it throws a NullReferenceException in System.Web when method tries to call View.Render. Here is StackTrace: w System.Web.VirtualPath.GetCacheKey() w System.Web.Compilation.BuildManager.GetCacheKeyFromVirtualPath(VirtualPath virtualPath, Boolean& keyFromVPP) w System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal

Hudson : warning MSB3245: Could not locate the assembly “nunit.framework”

…衆ロ難τιáo~ 提交于 2019-12-23 09:30:53
问题 I'm working in a Virtual Machine as a Hudson Slave. In the virtual machine, I add the path to the MSBuild I want to use : %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\; I added also the path to NUnit : C:\Program Files\NUnit 2.5.7\bin\net-2.0; And so, I can run the NUnit and MSBuild command lines in my VM. But I get this error when my Hudson Job build my solution : C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3245: Could not resolve this reference. Could

Nunit Testing MVC Site

余生长醉 提交于 2019-12-23 09:29:31
问题 I've run into a bit of an issue trying to unit test an MVC site I have: I require a lot of the ASP.NET environment to be running (generation of httpcontexts, sessions, cookies, memberships, etc.) to fully test everything. Even to test some of the less front end stuff needs memberships in order to properly work, and it's been finicky to get this all spoofed by hand. Is there a way to spin up an application pool inside of NUnit tests? That seems like the easiest way. 回答1: I'm not aware of a way

Nunit runs each test twice

徘徊边缘 提交于 2019-12-23 09:15:26
问题 I encounter a problem running my tests via NUnit. I dont know why but each test runs twice. The point is that on another laptop it normally runs only one time. Have anyone the same problem and know how to deal with it? 回答1: I had the same problem. In my case, I had both the Visual Studio extension and the NuGet package of the NUnit Test Runner installed. It seems they were both executing the tests, resulting in tests being run twice. Uninstalling the Visual Studio extension solved the issue.

Correct method for using the WPF Dispatcher in unit tests

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 08:56:32
问题 I am trying to follow the suggestions from Using the WPF Dispatcher in unit tests in order to get my nUnit test to run. When I write my unit test as below, it works: [Test] public void Data_Should_Contain_Items() { DispatcherFrame frame = new DispatcherFrame(); PropertyChangedEventHandler waitForModelHandler = delegate(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Data") { frame.Continue = false; } }; _myViewModel.PropertyChanged += waitForModelHandler; Dispatcher

Best practices for setting up a Visual Studio project for nUnit tests

折月煮酒 提交于 2019-12-23 08:36:22
问题 How do people set up their projects for Visual Studio and how do you reference the testable application ? Right now I've added a separate project creating a .dll to my solution which contains all the test cases and references nunit.framework , and it also references the main .exe file right from the Debug/ folder where VS generates the output. But I've no idea if that's a good idea - or what the best practices are, anyone want to share their practices ? 回答1: That sounds pretty good to me -

Best practices for setting up a Visual Studio project for nUnit tests

安稳与你 提交于 2019-12-23 08:35:23
问题 How do people set up their projects for Visual Studio and how do you reference the testable application ? Right now I've added a separate project creating a .dll to my solution which contains all the test cases and references nunit.framework , and it also references the main .exe file right from the Debug/ folder where VS generates the output. But I've no idea if that's a good idea - or what the best practices are, anyone want to share their practices ? 回答1: That sounds pretty good to me -

How do I ignore a test based on another test in NUnit?

*爱你&永不变心* 提交于 2019-12-23 07:11:06
问题 I'm writing some NUnit tests for database operations. Obviously, if Add() fails, then Get() will fail as well. However, it looks deceiving when both Add() and Get() fail because it looks like there's two problems instead of just one. Is there a way to specify an 'order' for tests to run in, in that if the first test fails, the following tests are ignored? In the same line, is there a way to order the unit test classes themselves? For example, I would like to run my tests for basic database

How do I ignore a test based on another test in NUnit?

不想你离开。 提交于 2019-12-23 07:10:27
问题 I'm writing some NUnit tests for database operations. Obviously, if Add() fails, then Get() will fail as well. However, it looks deceiving when both Add() and Get() fail because it looks like there's two problems instead of just one. Is there a way to specify an 'order' for tests to run in, in that if the first test fails, the following tests are ignored? In the same line, is there a way to order the unit test classes themselves? For example, I would like to run my tests for basic database

How to get unit test method attributes at runtime from within an NUnit test run?

此生再无相见时 提交于 2019-12-23 07:09:12
问题 I store various information about a given test (IDs for multiple bug tracking systems) in an attribute like so: [TestCaseVersion("001","B-8345","X543")] public void TestSomethingOrOther() In order to fetch this information during the course of a test, I wrote the below code: public string GetTestID() { StackTrace st = new StackTrace(1); StackFrame sf; for (int i = 1; i <= st.FrameCount; i++) { sf = st.GetFrame(i); if (null == sf) continue; MethodBase method = sf.GetMethod(); if (method