xunit.net

xUnit.net equivalent for TestContext.AddResultFile()

房东的猫 提交于 2019-12-10 14:47:23
问题 When using MSTest, I believe it's possible to add result files that will appear as attachments in the build reports in TFS (we're using 2015 FWIW), using TestContext.AddResultFile("filename"); Is there an way of doing this if we're using xUnit.net, short of switching back to MSTest or another test framework? 来源: https://stackoverflow.com/questions/37411644/xunit-net-equivalent-for-testcontext-addresultfile

.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

Xunit not working using Visual Studio Team Services Build VNext

拈花ヽ惹草 提交于 2019-12-10 10:48:17
问题 After following several blogs detailing how to get xUnit working with Team Services Build vNext: http://tech.trailmax.info/2014/01/run-xunit-in-hosted-team-foundation-service/ Running unit tests in TFS/VSO Build vNext using xUnit adapter http://www.donovanbrown.com/post/2015/06/15/how-to-run-xunit-test-with-vnext-build None of which worked for me. From examining the build logs I get the following warnings for each of my test assemblies. -------------------- Warning: [xUnit.net 00:00:00

Getting started with automated integration/unit testing in an existing code base

﹥>﹥吖頭↗ 提交于 2019-12-10 07:46:57
问题 Background: We have been handed over a very large codebase (1.4 million lines) that is primarily in C#. The application consists primarily of asp.net 2.0 style asmx web services accessing data in a SQL server 2008 database and also in various XML files. There are no existing automated tests in place. We have an automated nightly build in place (CC.NET). We want to introduce some level of automated testing, but refactoring in granular level unit tests for this amount of code seems unlikely.

How to add support for xunit's Theory attribute in Approvaltests

心不动则不痛 提交于 2019-12-10 04:25:02
问题 When I try to use approvals with my unit test decorated with [Theory] attribute it says: System.Exception: System.Exception : Approvals is not set up to use your test framework. It currently supports [NUnit, MsTest, MbUnit, xUnit.net] To add one use ApprovalTests.StackTraceParsers.StackTraceParser.AddParser() method to add implementation of ApprovalTests.StackTraceParsers.IStackTraceParser with support for your testing framework. To learn how to implement one see http://blog.approvaltests.com

App.config for Xunit

こ雲淡風輕ζ 提交于 2019-12-10 04:03:19
问题 I'm writing some xUnit tests for some helper classes that relies on some configuration settings, usually stored in App.config or Web.config of the executing project. The config looks like this: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="FileNamePattern" value="\\d{8}_\\w{4:20}\.png"/> <!-- and the likes --> </appSettings> </configuration> I'm running xUnit 1.9 with the GUI runner (xunit.gui.clr4.exe) and xUnit console runner (on the Jenkins CI server).

XUnit Assertion for checking equality of objects

社会主义新天地 提交于 2019-12-09 05:02:39
问题 I am using XUnit framework to test my C# code. Is there any assert method available in this framework which does the object comparison? My intention is to check for equality of each of the object's public and private member variables. I tried those alternatives but seldom it works: 1) bool IsEqual = (Obj1 == Obj2) 2) Assert.Same(Obj1, Obj2) which I couldnt understand what happens internally 回答1: You need to have a custom comparer to achieve this, when you compare objects otherwise they are

Running code on assembly load in xUnit

本秂侑毒 提交于 2019-12-08 17:26:14
问题 I am using the Effort library as a mock database, and it has some initialization code that has to run on assembly load. I have tried adding this initialization code in a static constructor that is referenced from every test via a base class constructor but this did not meet the requirements of the library. An answer to a similar question here mentions an AssemblyInitialize attribute, but this is not applicable to xUnit - xUnit has no way of running code on assembly load. I also asked on the

Faking/mocking an interface gives “no default constructor” error, how can that be?

二次信任 提交于 2019-12-08 17:10:04
问题 I'm trying to write a unit test of a repository implementation. The repository uses RavenDB as a database. For the unit tests, I would like to mock the RavenDB parts. In order to create the mocks (fakes) I'm using FakeItEasy. I figured there wouldn't be any problems with the mocking/faking since the RavenDB API is accessed through interfaces. I do however have a problem when trying to instantiate a specific mock. The relevant parts of my unit test code looks like this: [Fact] public void Test

Creating a IEqualityComparer<IEnumerable<T>>

回眸只為那壹抹淺笑 提交于 2019-12-08 02:53:10
问题 I'm using xUnit and it doesn't have a way to determine if 2 IEnumerable<T> are equal if T is custom type. I've tried using LINQ SequenceEqual but again as the instances of T are different this returns false; Here is a basic test with a non-working IEqualityComparer [Fact] public void FactMethodName() { var one = new[] { new KeywordSchedule() { Id = 1 } }; var two = new[] { new KeywordSchedule() { Id = 1 } }; Assert.Equal(one, two, new KeywordScheduleComparer()); } public class