Tag: 测试

NUnit:在TearDown中访问失败消息()

我正在尝试将NUnit中运行的自动化测试的结果记录在一个小型数据库中,以便数据易于访问并且由于各种原因更安全地记录。 (大约有550个自动化测试并运行它们都需要数天) 我已经可以访问测试的结束状态(Passed / Failed / Error / Cancelled / Skipped等..)但我想记录额外的细节。 我希望在TearDown()中做到这一点。 这是我能找到的最接近的东西,但没有给我答案: https : //groups.google.com/forum/?fromgroups =#! msg / nunit- discuss / lXxwECvpqFc / IbKOfQlbJe8J 想法?

使用NUnit Console Runner在文件夹下运行所有​​测试

我正在尝试使用NUnit Runners 2.6.4在我的测试文件夹中运行所有测试程序集。 我当前的命令如下所示: /nologo /noshadow /framework:net-4.0 /xml:.\test\TestResults.xml .\test\*.Test.dll 不幸的是,Nunit只抛出一个System.ArgumentException:路径中的非法字符。 无论如何我能做到这一点吗?

Visual Studio 2012伪造的UnitTestIsolation工具无法初始化

刚刚安装vs 2012更新2( http://www.microsoft.com/en-us/download/details.aspx?id=36833 ),所以我可以使用vs fakes / shims来测试一些难以测试的代码。 当我创建假assembly并且所有引用都按预期添加到unit testing项目中时,一切都编译得很好。 但是在任何测试中运行以下代码…… using (ShimsContext.Create()) { //Doesn’t matter whats in here } 引发以下exception…… Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException : UnitTestIsolation instrumentation failed to initialize. Please restart Visual Studio and rerun this test 堆栈跟踪完全exception…… Test ‘Abot.Tests.Unit.Core.HapHyperLinkParserTest.HyperLinkParserTest.GetLinks_AreaTags_ReturnsLinks’ failed: Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException : UnitTestIsolation instrumentation failed to initialize. Please restart Visual Studio and rerun this test at […]

在Visual Studio的快递版本中进行TDD的最佳方式(例如VB Express)

我一直在寻找为我正在编写的一个应用程序(OLE对象的OLE包装器)做一些测试驱动开发。 唯一的问题是我正在使用Visual Studio的快速版本(目前),目前我正在使用VB express,但有时我使用C#express。 是否可以在快递版本中进行TDD? 如果是这样的话,那是什么呢? 干杯。 编辑。 根据事物的外观我将不得不购买完整的视觉工作室,以便我可以做集成TDD,希望预算中有钱购买副本:)。 现在我想我会像所有人都说的那样使用Nunit。

如何使用构造函数dependency injectionunit testingasp.net核心应用程序

我有一个asp.net核心应用程序,它使用在应用程序的startup.cs类中定义的dependency injection: public void ConfigureServices(IServiceCollection services) { services.AddDbContext(options => options.UseSqlServer(Configuration[“Data:FotballConnection:DefaultConnection”])); // Repositories services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); // Services services.AddScoped(); services.AddScoped(); // new repos services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); 这允许这样的事情: [Route(“api/[controller]”)] public class MatchController : AuthorizedController { private readonly IMatchService _matchService; private readonly IMatchRepository _matchRepository; private readonly IMatchBetRepository _matchBetRepository; private readonly IUserRepository _userRepository; private readonly ILoggingRepository […]

通过递归遍历所有属性的属性来比较两个对象?

我已经编写了一个测试方法,用于比较一个类的两个实例(给出了类型兼容性的假设)。 我自豪地检查了所有的公共财产,确保返回一个差异列表。 问题是某些属性是包含自己属性的对象(子属性,如果可以的话)。 通过逐步完成流程,我可以看到这些没有被比较。 如何设计深入调用并比较所有子属性的调用? 如果方法相对简单,则额外奖励。 🙂 public static class Extensions { public static IEnumerable DiffersOn( this Generic self, Generic another) where Generic : class { if (self == null || another == null) yield return null; Type type = typeof(Generic); IEnumerable properties = type.GetProperties( BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo property in properties) { var […]

如果没有针对每个文本框的唯一测试,如何为null或为空,我如何检查多个文本框?

我在表单上有大约20个文本字段,用户可以填写。 我想提示用户在任何文本框中输入任何内容时都要考虑保存。 现在,对它的测试真的很长而且很混乱: if(string.IsNullOrEmpty(txtbxAfterPic.Text) || string.IsNullOrEmpty(txtbxBeforePic.Text) || string.IsNullOrEmpty(splitContainer1.Panel2) ||…//many more tests 有没有办法可以使用像任何数组的数组,其中数组由文本框组成,我检查它? 还有哪些方法可以非常方便地查看自程序启动以来是否有任何更改? 我应该提到的另一件事是有一个日期时间选择器。 我不知道我是否需要测试它,因为datetimepicker永远不会为null或为空。 编辑:我将答案纳入我的程序,但我似乎无法使其正常工作。 我按如下所示设置测试并继续触发Application.Exit()调用。 //it starts out saying everything is empty bool allfieldsempty = true; foreach(Control c in this.Controls) { //checks if its a textbox, and if it is, is it null or empty if(this.Controls.OfType().Any(t => string.IsNullOrEmpty(t.Text))) { //this means soemthing was […]

如何将Image对象与C#.NET进行比较?

我们可以用C#比较两个Image对象吗? 例如,检查它们是否相等,或者甚至更好地检查它们的像素有多相似? 如果可能,怎么样?

有没有办法获得基于任意xml的System.Configuration.Configuration实例?

我正在尝试对我编写的自定义ConfigurationSection进行unit testing,并且我想将一些任意配置XML加载到每个测试的System.Configuration.Configuration中(而不是将测试配置xml放在Tests.dll中)。配置文件。也就是说,我想做这样的事情: Configuration testConfig = new Configuration(“…”); MyCustomConfigSection section = testConfig.GetSection(“mycustomconfigsection”); Assert.That(section != null); 但是,看起来ConfigurationManager只会为您提供与EXE文件或计算机配置关联的配置实例。 有没有办法将任意XML加载到Configuration实例中?