xunit

How do I skip specific tests in xUnit based on current platform

微笑、不失礼 提交于 2019-12-30 03:38:07
问题 I have an assembly that I've built on Windows I want to run the xUnit tests on mono in Linux. However, I have found that while 400 of these tests can run (in order), that certain tests either hang the xUnit runner, or bring it down entirely. I don't care if certain tests are not able to run on Linux, certain tests are to do with the DTC and some unmanaged gumph that we don't need to support there. What I do want however, is to apply an ignore to those tests, and have the fact that the test

show XML in HTML with inline stylesheet

陌路散爱 提交于 2019-12-25 08:16:02
问题 It's not an duplicate, the problem ist not show an xml in html, rather to show xml with occasional stylesheets for single lines. i'm looking since hourse for an solution to show xml in a html page with inline css. Background: Input data is an xml file, what will be compared with another xml file in java. The comparison is processed by org.custommonkey.xmlunit. Now i like to transform the xml via xslt and the xpathes from the comparison result of xunit. Input XML (Multilevel, but for this

Could not load type Castle.Proxies.IReadinessProxy when running xUnit integration tests in parallel with Autofac

和自甴很熟 提交于 2019-12-25 01:18:28
问题 I am having an issue that I've been many days unable to resolve. I use xUnit with a given-then-when abstraction to make tests more readable. I am using a wrapper over EventStore and running some integration tests. They all go well.. except one that fails when running all in parallel (and xUnit runs in parallel), but if I run them all sequentially they all succeed. I cannot understand why this would be an issue because every single fact is supposed to run the constructor (the given) and the

Exception not being thrown in setter

荒凉一梦 提交于 2019-12-24 22:33:59
问题 I've created a class "BankAccount.cs" and am using xunit to test it. I'm testing whether the constructor throws an ArgumentException if it's provided with an empty string as an argument (the argument is the bank account number as a string). My test fails because no Exception is being thrown - I can't figure out why not. It appears that the constructor isn't even being called; if I let the constructor throw an Exception (rather than implementing this in the setter of AccountNumber), none is

Error on initialize a DbSet without key: Unable to track an instance of type 'MyEntity' because it does not have a primary key

删除回忆录丶 提交于 2019-12-24 17:12:17
问题 I have a DbContext which has a Dbset without Key. It works in the application, which only queries the table. public class MyDbContext : DbContext, IMyDbContext { public MyDbContext(DbContextOptions<MyDbContext> options) : base(options) { } public DbSet<MyEntity> MyEntities { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity<MyEntity>().HasNoKey(); // No key modelBuilder.ApplyConfigurationsFromAssembly(typeof(MyDbContext).Assembly); } } I

Casperjs 1.1 does not generate XUnit xml file

守給你的承諾、 提交于 2019-12-24 11:47:44
问题 I am running CasperJS tests. I tried to generate xUnit xml file in output rendering. But this fails when ever a single FAILure occurs. Actually the executing stopped when a single FAIL occurs. Here is the script that I am working on casper.test.begin('Site login', '', function suite(test) { casper.start(mysite, function () { test.assertExists('form#index', "Login Form found"); //Pass test.assertExists('form#index1', "Login Form found"); //Fail }); casper.run(function (){ test.done(); test

How to verify order of execution in XUnit Moq?

北城余情 提交于 2019-12-24 10:55:37
问题 I have the following class: public class Foo { public int Prop1 { get; set; } public string Prop2 { get; set; } public Stream TestStream; public WriteToTestStream() { ... } } WriteToTestStream writes to the TestStream . I want to write a Unit Test to make sure that Prop1 and Prop2 are being set before writing to the TestStream The properties should not be accessed once something is written to the TestStream . How can I define a Mock for WriteToTestStream in this case? How can I manipulate

Test explorer empty in VS2015 CE Update 3 with xUnit

◇◆丶佛笑我妖孽 提交于 2019-12-24 07:25:55
问题 I just upgraded VS2015 CE to Update 3 and realized that Test Explorer stopped working properly. I had 3 test projects, all of them with these NuGet packages: <package id="Castle.Core" version="3.3.3" targetFramework="net452" /> <package id="FluentAssertions" version="4.12.0" targetFramework="net452" /> <package id="MediatR" version="2.1.0" targetFramework="net452" /> <package id="Moq" version="4.5.16" targetFramework="net452" /> <package id="Newtonsoft.Json" version="6.0.4" targetFramework=

FluentAssertions, making sure IEnumerable contains only single element

狂风中的少年 提交于 2019-12-24 05:42:51
问题 I am writing unit tests and I have something that looks like this: [Fact] public void GetFoos_only_gets_foo1() { _foo1.included = true; //Foo object _foo2.included = false; //Foo object _sut.GetFoos().Should().OnlyContain(_foo1); // this doesn't work, is there a specific syntax to use? } And GetFoos() returns and IEnumberable<Foo> 回答1: OnlyContain expects a predicate - GetFoos().Should().OnlyContain(x => _foo1.Equals(x)); 回答2: Try this page as see if it helps. https://github.com/dennisdoomen

Net Core Integration Test: Run Startup.cs and Configuration from other Program

不问归期 提交于 2019-12-24 04:34:18
问题 We are creating an Integration Unit test (Xunit), which is calling the Real Application Startup.cs. For some reason, Real project can read Configuration file/property correctly, however running it from the Integration test, it cannot read it. Its not placing anything into Configuration (conf) variable below. How would I resolve this? The reason is its not picking up is its not reading the internal dependency injection new from Net Core 2.2 which reads Configuration file. Trying to use