Thursday, March 31, 2016

xUnit.net: Extensions Config v3.3.0

I recently made several updates to the xunit.extensions.config library, which allows you to configure theory data from your app.config file. Here are the links to the source and the NuGet package:

New Features

  • Named Parameter Support

You no longer need to configure your data by parameter index. You can now name your data for each parameter, making the configuration much easier to read and understand.

  • AppSettings Support

You can now use the standard AppSettings section of the App.config to configure your data. If no settings are found, then the framework will fallback to trying to use the standard config section.

  • Default Namespace Option

You can now provide a default namespace for your tests. This reduced the amount of redundant text in your config file, and makes test names much more concise and easy to read.

  • Extensible Data Provider

Don't want to use the existing data providers? Would you rather use a database? Now you can! Just add an AppSettings key for "TestData.ServiceFactory" that provides the fully qualified name of a static method that returns an IConfigTestDataService, and the framework will try to use that to load configuration data.

Sample App.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="TestData.DefaultNamespace" value="Xunit.Extensions.Config.Tests2" />
    <add key="TestData[0].Name" value="SampleTest.FromConfig" />
    <add key="TestData[0].Data[0][Name]" value="Linq" />
    <add key="TestData[0].Data[0][Age]" value="7" />
    <add key="TestData[0].Data[0][IsFriendly]" value="true" />
  </appSettings>
</configuration>

Sample Unit Test

namespace Xunit.Extensions.Config.Tests2
{
    public class SampleTest
    {
        [Theory]
        [ConfigOrInlineData("Taboo", 5, false)]
        public void FromConfig(string name, int age, bool isFriendly)
        {
            Assert.Equal("Linq", name);
            Assert.Equal(7, age);
            Assert.Equal(true, isFriendly);
        }
    }
}

Enjoy,
Tom

2 comments:

  1. Additionally, you can make a booking anytime of the night or day we make it easy to make it easy for you to book the most desirable models for your special occasion in rudrapur. With our 24/7 operating hours, it won't matter when you decide to meet with one of our models. You'll also have an enjoyable and stimulating time thanks to our fantastic models. They won't be missed in a flash.
    what's app rudrapur girls number
    phone call lucknow girls
    hot call Mount Abu girls number.
    call dehradun girls phone number
    call haridwar girls phone number
    what's app beawar girls number

    ReplyDelete
  2. Really Good Work Done By You...However, stopping by with great quality writing, it's hard to see any good blog today.
    KaliCrack
    Free YouTube Download Premium CRACK
    Crack Softwares Free Download

    ReplyDelete

Real Time Web Analytics