nunit

System.BadImageFormatException:Could not load file or assembly … incorrect format when trying to install service with installutil.exe

冷暖自知 提交于 2019-12-21 03:31:49
问题 I know i am going to ask duplicate question but my scenario is totally different i think so because when i go to do unit testing with nunit tool of my program then in NUnit this error happen "NewTest.testtest (TestFixtureSetUp): SetUp : System.BadImageFormatException : Could not load file or assembly 'AUTO_REPAIR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format." I wonder why this error is

What happended to nunit extensions/rowtest?

非 Y 不嫁゛ 提交于 2019-12-21 03:17:47
问题 In NUnit 2.4.7, nunit.framework.extensions.dll was included which made it possible to do RowTests. When downloading the newest version (2.5.8) I can't find it. What happened to it? 回答1: Instead of using RowTest , you can use TestCase . A previous testing using RowTest would look like: [RowTest] [Row("foo", false)] [Row("", true)] public void Some_test(string value, bool expected) { // test } And the same thing with TestCase looks like this: [TestCase("foo", false)] [TestCase("", true)] public

testing method which create a new thread and result we get from event ( NUnit 2.6 )

只愿长相守 提交于 2019-12-21 02:59:07
问题 I have class which have one public method Start , one private method and one event Finishing . Start call new Thread( private_method ) . Private method return value using event. When this method finish their work, then call this event. Now I want to write test to this class. If I write it like this: [Test] public void Test1() { SomeClass someObject = new SomeClass(); someObject.Finishing += new SomeClass.FinishingEventHandler((sender, a) => { Assert.True(false); }); someObject.Start(); //

How to load my test data in C#?

冷暖自知 提交于 2019-12-21 02:57:35
问题 I am struggling to find an easy way to load my test data in C#. In Java, I load a resource using the following code: ... public static InputStream loadResource(String resource) throws LoadException { InputStream is = TestUtils.class.getResourceAsStream(resource); if (is == null) { throw new LoadException("Error loading '" + resource + "'"); } return is; } ... public static void main(String[] args) { InputStream is = TestUtils.loadResource("/resourcelocation"); } I tried to use C# resource

TeamCity incremental testing for .Net projects

半世苍凉 提交于 2019-12-21 02:38:18
问题 I'm building a modular WPF application. Each screen is a highly independent and isolated unit. The only thing shared - shell and a common library with a facade interface for the reusable services (message bus, persistence, window management etc). Since the modules are loosely coupled it doesn't make sense to retest everything when a single module changed. I want to test only what's changed. If there is a change in a common library - everything should be retested. From a source control diff

Using NUnit to perform integration tests with ASP.NET WebApi controllers

末鹿安然 提交于 2019-12-20 20:27:26
问题 I'm trying to setup a test using NUnit to perform some integration testing of ASP.NET WebApi controllers. I've found a couple articles discussing In-Memory hosting using HttpServer that appears to simplify things by not needing a web server hosting everything. ASP.NET Web API: in-memory hosting ASP.NET Web API integration testing with in-memory hosting The problem is the only response I ever get is 404-Not Found. The controller are working when manually tested via a browser or Fiddler. The

Using NUnit to perform integration tests with ASP.NET WebApi controllers

耗尽温柔 提交于 2019-12-20 20:27:10
问题 I'm trying to setup a test using NUnit to perform some integration testing of ASP.NET WebApi controllers. I've found a couple articles discussing In-Memory hosting using HttpServer that appears to simplify things by not needing a web server hosting everything. ASP.NET Web API: in-memory hosting ASP.NET Web API integration testing with in-memory hosting The problem is the only response I ever get is 404-Not Found. The controller are working when manually tested via a browser or Fiddler. The

单元测试之道(使用NUnit)

旧时模样 提交于 2019-12-20 20:12:27
首先来看下面几个场景你是否熟悉 1、你正在开发一个系统,你不断地编码-编译-调试-编码-编译-调试……终于,你负责的功能模块从上到下全部完成且编译通过!你长出一口气,怀着激动而又忐忑的心情点击界面上的按钮,顿时你刚刚的轻松感烟消云散:系统无法正常工作,你想读的数据显示不出来,你想存的东西也送不到数据库……于是,你再次回到IDE里,设断点、调试、一层一层跟踪,当你精疲力尽终于将数据送到数据库里,你又发现了其它问题,于是你继续设断点、调试、编译、调试…… 2、你狂躁地敲击着键盘和鼠标,咒骂着不断出现的bug:啊?这里怎么没返回值啊!哎?这里不该是0啊!不对啊,这里怎么没数据……你永远不知道还有多少bug,你也永远不知道你的改动会不会引入其它bug——这里有几十个甚至上百个类,几百几千个方法!我不能都照顾到啊!你感觉bugs像敲击鼹鼠游戏中的鼹鼠:打下了这个,另一个又从其它洞口露出头来…… 3、也许是毕业答辩的演示,也许是客户的审查,你小心地打开自己要演示的系统,进行着预定的操作,忽然,有个功能不能正常运行,你大汗淋漓,在答辩老师或者客户质疑且不满的目光下你试了又试,但还是于事无补……于是,答辩老师可能扭头便走,客户可能愤然离去,然后离去的还有你的学位证和项目奖金。当后来你检查代码时,发现这一切竟然只是因为一个底层工具类中一个方法输出结果为空。

如何使用Assert验证是否抛出了异常?

安稳与你 提交于 2019-12-20 16:47:34
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 如何使用Assert(或其他Test类?)来验证是否抛出了异常? #1楼 好吧,我几乎可以总结一下之前所有其他人所说的内容......无论如何,这里是我根据好的答案建立的代码:)剩下要做的就是复制和使用...... /// <summary> /// Checks to make sure that the input delegate throws a exception of type TException. /// </summary> /// <typeparam name="TException">The type of exception expected.</typeparam> /// <param name="methodToExecute">The method to execute to generate the exception.</param> public static void AssertRaises<TException>(Action methodToExecute) where TException : System.Exception { try { methodToExecute(); } catch (TException) { return; } catch

nUnit Assert.That(method,Throws.Exception) not catching exceptions

六月ゝ 毕业季﹏ 提交于 2019-12-20 15:46:16
问题 Can someone tell me why this unit test that checks for exceptions fails? Obviously my real test is checking other code but I'm using Int32.Parse to show the issue. [Test] public void MyTest() { Assert.That(Int32.Parse("abc"), Throws.Exception.TypeOf<FormatException>()); } The test fails, giving this error. Obviously I'm trying to test for this exception and I think I'm missing something in my syntax. Error 1 TestCase '.MyTest' failed: System.FormatException : Input string was not in a correct