Data Driven Testing in XUnit for Selenium tests

ExecuteAutomation
ExecuteAutomation
Published in
1 min readSep 5, 2021

Working with Data is the most important part of any testing. XUnit has different ways to access the data for the test method and in this article we will be discussing about the same in most easiest way.

Previous Articles

XUnit with Selenium

Sharing Selenium WebDriver Context in XUnit with DI

Data access via XUnit [Inline Data]

XUnit [Theory] attribute helps us to access with Inline data for test method. The way we can do is like this

[InlineData("admin", "password")]

The test method should be decorated with [Theory] attribute while working with data access in XUnit

Here is the complete test method

Data access via XUnit [MemberData]

Another convenient way to access data for [Theory] test method is via [MemberData]. [MemberData] attribute helps to read data via IEnumerable<object[]> type

The IEnumerable<object[]> can be defined as shown below

The above Data can be accessed via [MemberData] declaration can be defined as shown below

[Theory]        
[MemberData(nameof(Data))]

Here is the complete test with MemberData as shown below

Complete Video

Here are the complete videos as shown below

Data access via [InlineData] attribute

Data Access via [MemberData]

Hope you like the article.

Here is the complete playlist of XUnit video series in ExecuteAutomation YouTube channel

--

--

ExecuteAutomation
ExecuteAutomation

ExecuteAutomation Ltd is a Software testing and its related information service company founded in 2020. Info available in YouTube and Udemy as video courses .