xunit.net

Having trouble enabling the NuGet version of XUnit.NET on Team Build 2013

有些话、适合烂在心里 提交于 2019-12-24 03:43:33
问题 I would like to use Xunit as a test framework. I've created test project, added two nuget packages (xunit and xunit.runner.visualstudio) and everything works great. Visual Studio discover tests. But how can I configure TFS 2013 build to discover that tests? What's the proper way to do that? I found a lot of tips but I think all are related to old test runner which was downloaded as Visual Studio Extensions instead of the current NuGet package. 回答1: With the introduction of the NuGet based

Using FakeItEasy, is it possible to create a dummy object of a type that takes generic type parameters

本小妞迷上赌 提交于 2019-12-23 16:28:27
问题 I have the following test: [Fact] public void StartProgram_CallsZoneProgramStart() { var zone = A.Fake<Zone>(); zone.StartProgram(); A.CallTo(() => zone.ZoneProgram.Start(null, A.Dummy<ActionBlock<InterruptInfo>>())).MustHaveHappened(Repeated.Exactly.Once); } It's creating a dummy of type ActionBlock<InterruptInfo> which is being passed into the MustHaveHappened call. zone.StartProgram definitely calles the zone.ZoneProgram.Start method, but this call is not seen by FakeItEasy. It returns the

What is the attribute in Xunit that's similar to TestContext in Visual studio tests?

谁都会走 提交于 2019-12-23 09:32:45
问题 We are migrating from visual studio tests to xunit.. In VStests we can access run time test parameters using TestContext. I am looking to set a global variable in the tests supplied at run time from command line using msbuild. Can someone help in finding out the TestContext equivalent in xunit? 回答1: There is no TestContext in XUnit. I could not find a canonical way to deal with environment parameters when running the tests, so I relied on a JSON file. E.g.: { "Browser": "Chrome", "BasePath":

Why does the color after Image.Clear(x) not exactly equal the color x?

China☆狼群 提交于 2019-12-23 03:50:35
问题 The sample code for this issue is largely self-explanatory, so: [Fact] private void Color_in_should_equal_color_out() { var bitmap = new Bitmap(128,128,PixelFormat.Format32bppArgb); var color = Color.FromArgb(30,60,90,120); using (var g = Graphics.FromImage(bitmap)) { g.Clear(color); } var result = bitmap.GetPixel(0,0); Assert.Equal(color, result); } In this instance I would expect the color of the background to be identical to the color I cleared it to. Instead I get this: Assert.Equal()

AutoFixture mixing PropertyData with multiple entries and AutoData (using AutoMoqCustomization)

一个人想着一个人 提交于 2019-12-23 03:15:09
问题 I've looked at both of these similar SO questions: AutoFixture: PropertyData and heterogeneous parameters AutoFixture CompositeDataAttribute does not work with PropertyDataAttribute And they're awesome and get me nearly there. But both examples use only one entry in the emitted IEnumerable PropertyData (i.e.: yield return new object[] { 2, 4 }; -- see: https://stackoverflow.com/a/16843837/201308) This works, but it blows up whenever I want to do test over more than one object[] test data. I

AutoFixture mixing PropertyData with multiple entries and AutoData (using AutoMoqCustomization)

左心房为你撑大大i 提交于 2019-12-23 03:15:09
问题 I've looked at both of these similar SO questions: AutoFixture: PropertyData and heterogeneous parameters AutoFixture CompositeDataAttribute does not work with PropertyDataAttribute And they're awesome and get me nearly there. But both examples use only one entry in the emitted IEnumerable PropertyData (i.e.: yield return new object[] { 2, 4 }; -- see: https://stackoverflow.com/a/16843837/201308) This works, but it blows up whenever I want to do test over more than one object[] test data. I

“Unit Tests 1” but beneath it the List is empty

依然范特西╮ 提交于 2019-12-23 01:52:27
问题 I cloned https://github.com/SonarSource/sonar-examples.git then opened a command prompt under SonarSource/sonar-examples/tree/master/projects/languages/csharp and run the following commands (based on "Unit Test Execution Results Import (C#, VB.NET)" @ docs.sonarqube.org/pages/viewpage.action?pageId=6389772): MSBuild.SonarQube.Runner.exe begin /k:"org.sonarqube:csharp-simple-sq-scanner-msbuild" /n:"C# :: Simple Project :: SonarQube Scanner for MSBuild" /v:"1.0" /d:sonar.cs.xunit.reportsPaths="

xUnit and Moq do not support async - await keywords

送分小仙女□ 提交于 2019-12-22 01:27:07
问题 I am trying to discover how to apply the async and await keywords to my xUnit tests. I am using xUnit 1.9 and Async CTP 1.3. Here is my test case I have an interface which specifies one asynchronous method call public interface IDoStuffAsync { Task AnAsyncMethod(string value); } I have a class which consumes the interface and calls the async method public class UseAnAsyncThing { private readonly IDoStuffAsync _doStuffAsync; public UseAnAsyncThing(IDoStuffAsync doStuffAsync) { _doStuffAsync =

Can you mark XUnit tests as Explicit?

一个人想着一个人 提交于 2019-12-20 17:35:04
问题 I'm making the transition from NUnit to XUnit (in C#), and I was writing some "Integrated Tests" (ITs) that I don't necessarily want the test runner to run as part of my automated build process. I typically do this for manually testing, when the full end to end process might not work because of environmental factors (missing data, etc.) In NUnit, you could mark a test with the Explicit attribute and it would just get skipped by the test runner (unless you marked the test with a specific

How to run setup code only once in an xUnit.net test

放肆的年华 提交于 2019-12-20 16:54:06
问题 I'm trying to setup my tests using Xunit. I have a requirement to delete all images in a folder start of the tests, and then each method does some image resizing and saves a copy of it's output to the folder. The folder should only be emptied once, and then each method will save their own image into the folder. When I use IUseFixture<T> , the ClearVisualTestResultFolder function is still being called before every test, so I only end up with one image in the folder. public class Fixture {