xunit.net

In xUnit.net, is it possible to run tests in order?

I know you generally should not depend on order for your unit tests, but in xunit is it possible to make your tests run in a certain order? ...

Are there any .NET web automation frameworks that support headless test execution?

Similar to htmlunit, but for use with C#. I've seen that you can use htmlunit with .NET via IKVM, but I'd like a native solution if at all possible. The aim is to add UI tests to our existing (xUnit.net) tests being run on the CI server. I'd like to be able to run UI tests in memory (since I don't want to be opening browser instances on...

Test class constructors not executing when running an xUnit Theory individually?

Toy example code: public abstract class testBase { public testBase() { //Some common test setup code, which will initialize ManagerClass } } public class someTests: testBase { public someTests() { //someTests-specific constructor code. } [Theory] [PropertyData("MyTestData")] public void test1(Foo foo) { ...

Running portion of a TeamBuild as x64 [for xunit.net tests]

Using Team Foundation Build, I'm invoking the xunit.net xunit task, which is /platform:AnyCpu, but my TeamBuild invocation of the TFSBuild.proj is vanilla. I have a number of tests that are x64 specific (`/platform:x64'), which choke with an ImageFormatException. I have also a test asembly that's marked x86 so it can't be all or nothing...

Getting Console output to display from Gallio & xunit.net

Previously when executing unit tests with xunit.net / testdriven.net I could see output written to the console (via Console.WriteLine) displayed in the output window. I'm now using the Gallio TestDriven.Net runner to execute xunit.net tests (Gallio TestDriven.Net Runner - Version 3.0.6 build 787) - and I'm finding it no longer captures ...

Execute unit tests serially (rather than in parallel)

I am attempting to unit test a WCF host management engine that I have written. The engine basically creates ServiceHost instances on the fly based on configuration. This allows us to dynamically reconfigure which services are available without having to bring all of them down and restart them whenever a new service is added or an old one...

xUnit.net Test Stripper [to remove test code embedded in binaries prior to deployment/shipping]

Is there a Test Stripper (as defined in xUnit Test Patterns) available that supports removing classes containing methods tagged as [Fact]s etc. plus the dependency on xunit.dll from binaries [as part of a build process] ? Further details of the full requirements and context are at this xUnit CodePlex post. Failing that (something that ...

How (strategy) to unit test properties (get/set) in BDD style?

I have a class (of many) that have properties. Some have logic in them and some don't. Assuming I want to test these properties, how do I go about doing that? Recently, I've been interested in BDD style for creating unit tests. see here and here. So I'd do a setup of the context - basically create the SUT and load up whatever is nee...

ReSharper doesn't see my Machine.Specification tests

I'm having a problem getting ReSharper to see the Machine.Specification "tests" I've written. The specs run in the ConsoleRunner from mSpec. When I try to "Run Unit Tests" in ReSharper, I get a message: "No tests found in file." The specs don't show the test markers. I created a folder in the ReSharper /bin/ folder and put the proper ....

Testing MVC Controller Action HttpAcceptAttribute Verbs

What is the best way to unit test the controller action HttpAcceptAttribute verbs? So far I have the following but it's so ugly even a mother couldn't love it and not very flexible. Is there a better way? [Fact] // using xUnit, mocking controller in class public void FilterControllerTestRemoveFilterByProductAttributeIsOfTypePost() { ...

Visual Studio "Run a method" vs "Utility tests"

I use XUnit and Resharper to run my tests. In a given project I usually have a few utility tests which are not really tests but exist purely so I can execute a bit of code easily. For example, I have a test which outputs my NHibernate mappings (I use Fluent NHibernate) to a temporary directory. I don't really like having these as tests, ...

NCover not covering an assembly?

I am having trouble getting NCover to properly cover a .dll. I have several test projects that use XUnit.NET and SubSpec to execute BDD-style specifications. All but one of these test suites runs perfectly in the version of NCover that comes with TestDriven.NET (1.5.8). However, I have one that refused to profile the actual tested assemb...

Migrate from MSTest to XUnit

We are thinking about moving our tests from MSTest to XUnit. Is there any migration application that takes a MSTest and migrates it to XUnit? Also, if not, what should I look out for when doing this? Thanks. JD. ...

easiest way to get continual unit tests running locally with visual alerts, with xUnit for C#/VS2008?

Hi, I'm currently using MSTest in VS2008 for unit tests, but I am looking at going to xUnit.net. Question - What would be the easiest way to get my unit tests running continually locally (on my PC) and with some sort of visual alert of pass / # of fails. i.e. similar to what we do in Ruby on Rails with autospec. THanks PS Interseste...

Xunit: Perform all 'Assert'ions in one test method?

Is it possible to tell xUnit.net to perform all e.g. Assert.True() in one test method? Basically in some of our use/testcases all assertions belong logically to one and the same 'scope' of tests and I have e.g. something like this: [Fact(DisplayName = "Tr-MissImpl")] public void MissingImplementationTest() { // parse...

Moq and accessing called parameters

I've just started to implement unit tests (using xUnit and Moq) on an already established project of mine. The project extensively uses dependency injection via the unity container. I have two services A and B. Service A is the one being tested in this case. Service A calls B and gives it a delegate to an internal function. This 'callb...

Should I test UDP server code, and if so - why and how?

I don't have much experience doing unit testing. From what I learned, code should be decoupled, and I should not strive to test private code, just public methods, setters, etc etc. Now, I have grasped some basic testing concepts, but I have troubles applying more advanced stuff to this case... Dependency Injection, Inversion of Control,...

xUnit false positive when comparing null terminated strings

I've come across odd behavior when comparing strings. First assert passes, but I don't think it should.. Second assert fails, as expected... [Fact] public void StringTest() { string testString_1 = "My name is Erl. I am a program\0"; string testString_2 = "My name is Erl. I am a program"; Assert.Equal<string>(testString_1, t...

Unit test for Web Forms MVP presenter has a null Model

I am using Web Forms MVP to write an DotNetNuke user control. When the 'SubmitContactUs' event is raised in my unit test the presenter attempts to set the 'Message' property on the Modal. However the View.Modal is null in the presenter. Shouldn't the Web Forms MVP framework automatically build a new View.Model object in the presente...

Where to put my xUnit tests for an F# assembly?

I'm working on my first 'real' F# assembly, and trying to do things right. I've managed to get xUnit working too, but currently my test module is inside the same assembly. This bothers me a bit, because it means I'll be shipping an assembly where nearly half the code (and 80% of the API) is test methods. What is the 'right' way to do t...