nunit测试中的System.accessviolationexception [英] System.accessviolationexception in nunit test
问题描述
我正在使用带有nUnit测试的Visual Studio 2012 / C#,并在简单测试中获得System.AccessViolationException ...
当我启动执行测试时选项,测试返回OK。
当我启动调试测试选项时,我得到System.AccessViolationException。
我认为我的配置中的东西不好。我很确定来源是好的并且没有隐藏的bug。
任何帮助都会有所帮助。
以下是代码:
Class1.cs
使用System;
namespace ClassLibrary1
{
public class Class1
{
public String test =1;
public Class1()
{
}
public void Test()
{
test =2;
}
}
}
UnitTest1.cs
使用ClassLibrary1;使用NUnit.Framework
;
名称空间UnitTestProject1
{
[TestFixture]
公共类UnitTest1
{
[测试]
public void TestMethod1()
{
Class1 classe = new Class1();
Assert.AreEqual(classe.test,1);
classe.Test();
Assert.AreEqual(classe.test,2);
}
}
}
我尝试了什么:
尝试重新安装VS2012 + nUnit但没有成功。
看起来这个VS bug:奇怪的访问违规例外
报告在这里:https://connect.microsoft.com/VisualStudio/feedback/details/911564/access-violation-exception-in-vs -hosting-process-when-debugging-application
并假设已在此.NET版本中修复:http://www.microsoft.com/en-us/download /details.aspx?id=42642
I'm using Visual Studio 2012 / C# with nUnit test, and get System.AccessViolationException on simple test...
When I launch the "Execute Test" option, the test returns OK.
When I launch the "Debug Test" option, I get System.AccessViolationException.
I think something in my config is not good. I'm pretty sure the source is good and has no hidden bug.
Any help will help.
Here is the code :
Class1.cs
using System; namespace ClassLibrary1 { public class Class1 { public String test = "1"; public Class1() { } public void Test() { test = "2"; } } }
UnitTest1.cs
using ClassLibrary1; using NUnit.Framework; namespace UnitTestProject1 { [TestFixture] public class UnitTest1 { [Test] public void TestMethod1() { Class1 classe = new Class1(); Assert.AreEqual(classe.test, "1"); classe.Test(); Assert.AreEqual(classe.test, "2"); } } }
What I have tried:
Try to reinstall VS2012 + nUnit with no success.
It looks like this VS bug: Weird Access Violation Exception
Reported here: https://connect.microsoft.com/VisualStudio/feedback/details/911564/access-violation-exception-in-vs-hosting-process-when-debugging-application
And assumingly fixed in this .NET release: http://www.microsoft.com/en-us/download/details.aspx?id=42642
这篇关于nunit测试中的System.accessviolationexception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!