xunit

Pass complex parameters to [Theory]

本秂侑毒 提交于 2020-01-08 14:03:32
问题 Xunit has a nice feature: you can create one test with a Theory attribute and put data in InlineData attributes, and xUnit will generate many tests, and test them all. I want to have something like this, but the parameters to my method are not 'simple data' (like string , int , double ), but a list of my class: public static void WriteReportsToMemoryStream( IEnumerable<MyCustomClass> listReport, MemoryStream ms, StreamWriter writer) { ... } 回答1: There are many xxxxData attributes in XUnit.

Pass complex parameters to [Theory]

老子叫甜甜 提交于 2020-01-08 14:02:11
问题 Xunit has a nice feature: you can create one test with a Theory attribute and put data in InlineData attributes, and xUnit will generate many tests, and test them all. I want to have something like this, but the parameters to my method are not 'simple data' (like string , int , double ), but a list of my class: public static void WriteReportsToMemoryStream( IEnumerable<MyCustomClass> listReport, MemoryStream ms, StreamWriter writer) { ... } 回答1: There are many xxxxData attributes in XUnit.

XUnit Net Core Web API Integration Test: “The ConnectionString property has not been initialized.”

不羁的心 提交于 2020-01-06 08:46:15
问题 Just trying to build an Integration Test project for a NET Core Web API. So I've followed a few examples, including this one (https://dotnetcorecentral.com/blog/asp-net-core-web-api-integration-testing-with-xunit/) and naturally, I run into issues. When I run the simple GET test I get an exception: "System.InvalidOperationException : The ConnectionString property has not been initialized." Any help would be appreciated. 回答1: For server = new TestServer(new WebHostBuilder().UseStartup<Startup>

Trying to run nosetests outputing with xunit and using suite

隐身守侯 提交于 2020-01-05 09:35:14
问题 I'm trying to run nosetests in web2py using suite and outputing with xunit, it creates the xml files but even if the console shows that there were errors, but, they are not been written in the xml file The .py script: suite = TestLoader().loadTestsFromTestClass(globals()[strArchivo+strDirectorio]) noseargs = ['fake','--processes=0','v=0','--process-timeout=60', '--with-xunit', '--xunit-file=applications/output.xml','--verbosity=0'] nose.run(argv = noseargs,suite = suite) The console output:

How to unit-test action with return type ActionResult<T>?

倖福魔咒の 提交于 2020-01-05 05:53:09
问题 My question is very similar to this one: How to unit-test an action, when return type is ActionResult? The problem is that my question mixes in the generic ActionResult<T> type, async , and Ok(...) . I can't seem to adapt linked question's answer to the generic situation. Or possibly my scenario is subtly different. Here's a repro. Create new ASP.NET Core Web Application of "API" type. Add a new xUnit .NET Core test project to the solution, that references the API project (as well as any

How to pass multiple parameters to tests that share the same setup code in Matlab xUnit?

余生颓废 提交于 2020-01-03 15:54:57
问题 According to "How to Write Tests That Share Common Set-Up Code" is it possible to: function test_suite = testSetupExample initTestSuite; function fh = setup fh = figure; function teardown(fh) delete(fh); function testColormapColumns(fh) assertEqual(size(get(fh, 'Colormap'), 2), 3); function testPointer(fh) assertEqual(get(fh, 'Pointer'), 'arrow'); But I couldn't make it work with more parameters: function test_suite = testSetupExample initTestSuite; function [fh,fc] = setup fh = figure; fc =

IsType<T> and IsType(object, object) throwing IsTypeException

倖福魔咒の 提交于 2020-01-03 08:31:36
问题 I am attempting to assert that an object being returned by a method call is of the type List<MyClass> , so using xUnit I have tried the following: var expected = typeof(List<MyClass>); var actual = typeof(method()); Assert.IsType<List<MyClass>>(actual); Assert.IsType(expected, actial); Both of the above throw the IsTypeException however if I perform: var areSameType = expected == actual areSameType is true . So is there something going on deeper down that I am not accounting for? Docs: http:/

Running (x)Unit Tests on TFS Build Pipeline

≡放荡痞女 提交于 2020-01-02 10:07:42
问题 I am merely a beginner and still trying to learn about TFS and its continuous integration workflow. Having that said, this could as well be a stupid question to ask as I might be missing on a simple detail, though any help or advice would be highly appreciated. So, I have a fairly simple Unit Test example written using .NET Core 2.0, which I would like to run as a test task on our TFS Server's CI Build pipeline. It pretty much looks something like this: using Microsoft.VisualStudio.TestTools

Mock HostingEnvironment.QueueBackgroundWorkItem in xunit test

眉间皱痕 提交于 2020-01-02 00:42:46
问题 I have a method using HostingEnvironment.QueueBackgroundWorkItem which I wish to unit test some behaviour before this call, however, the test is failing with System.InvalidOperationException : Operation is not valid due to the current state of the object. I suspect this I need to mock the HostingEnvironment but unaware of how to. 回答1: To resolve this issue I defined an interface public interface ITaskScheduler { void QueueBackgroundWorkItem(Action<CancellationToken> workItem); } In production

boost unit tests with xUnit Plugin in Jenkins do not work

試著忘記壹切 提交于 2020-01-01 14:57:34
问题 I am not a C programmer, but i have to run boost tests on my Jenkins. Now I have installed the xUnit plugin in Jenkins. I added a post-build action : "Publish xUnit test result report" Then, in this post-build step I added : "BoostTest-1.x (default)" Now I have the following options to set: https://www.dropbox.com/s/wxcny55rz2bqk6r/boost_jenkins_options.png The options I set are random, so please help me, I don't understand anything and I didn't find some tutorials. I have not worked with