Menu

Skip to content
  • Home
  • About
  • Color Coder
Hamid Mosalla
Twitter Email LinkedIn GitHub Stack Overflow RSS

Hamid Mosalla

Programming Adventures

xUnit

April 5, 2020 by Hamid Mosalla on .Net, XUnit

XUnit – Part 8: Using TheoryData Instead of MemberData and ClassData

I previously wrote about using MemberData, ClassData in this  post. The problem with those are their reliance on IEnumerable<object[]>. This can cause runtime issues even if we don’t get any errors at compile time. In this post I’m going to introduce a strongly typed option in xUnit called TheoryData. So in this post I’m going … →

 
February 2, 2020 by Hamid Mosalla on .Net, C#, XUnit

XUnit – Part 5: Share Test Context With IClassFixture and ICollectionFixture

xUnit has different mechanisms to share test context and dependencies. Not only it allows us to share different dependencies between tests, but also between multiple test classes. We can also choose to get a fresh set of data every time for our test. So in this post, I’m going to go though those mechanism with … →

 
January 26, 2020 by Hamid Mosalla on .Net, C#, XUnit

XUnit – Part 4: Parallelism and Custom Test Collections

As multi core processor and computers gain prevalence, the topic of Parallelism become more important. It allows us to use the computing resource we have available to the fullest. So by release of xUnit 2, we have the ability to run the tests in parallel. In this version, the tests are gathered into collection, and … →

 
January 20, 2020 by Hamid Mosalla on .Net, C#, XUnit

XUnit – Part 3: Action Based Assertions Assert.Raises and Assert.Throws

In my previous post, we saw how value and type based assertions works in xUnit. In this post I’m going to focus on assertions that check whether or not something happened. Specifically we look at assertions to check if an event is raised or an exception is thrown. Asserting if An Event Is Raised Let’s … →

 
January 12, 2020 by Hamid Mosalla on .Net, XUnit

XUnit – Part 2: Value and Type Based Assertions in xUnit

In xUnit and many other testing frameworks, assertion is the mean that we conduct our test. In other word we assert an expectation that something is true about a piece of code. There are many different types of assertion in xUnit that we can use. Normally assertions are based on different types of object, but … →

 
January 5, 2020 by Hamid Mosalla on .Net, C#, XUnit

XUnit – Part 1: xUnit Packages and Writing Your First Unit Test

I one of my previous post I said I’m going to write a series of articles on xUnit. I’m going to start from the begging which is installing xUnit packages. I’m also going to explain a little about other frameworks that might be used with xUnit to complement it. In the future I’ll go in … →

 
August 30, 2018 by Hamid Mosalla on .Net, C#, Unit Test

xUnit BeforeAfterTestAttribute: How to Run Code Before And After Test

Sometimes we need to run a piece of custom code before and after a test and set of tests. One example of this might be when we want to change the thread culture. In this case we change it before test start to run and restore it to its original after test is finished. One … →

 
August 16, 2018 by Hamid Mosalla on .Net, C#, Unit Test

xUnit: Control the Test Execution Order

Sometime in our tests, we need to control the test execution order. This mostly happens in our integration test and not as often as our unit tests. Some people might even argue that controlling the execution order of unit test is bad practice. You can read more about it here. The main reason to not … →

 
July 31, 2018 by Hamid Mosalla on .Net, C#, Unit Test

xUnit: Share an SUT Instance Between Two Class Using Collection

In my previous post I talked about how we can Share Expensive Object Between Tests By Using IClassFixture. My previous post is about situations when we want to share a class instance between all test methods. Because a test class is created once per test method so its constructor is executed per test methods. But … →

 
July 21, 2018 by Hamid Mosalla on .Net, C#, Unit Test

Share Expensive Object Between Tests By IClassFixture

When XUnit run a test method, it’s going to create a new object of our test class for each and everyone of our test method. This can create a problem when the creation of the object is expensive and slow our tests down. But there’s a solution to it, we can use IClassFixture to share … →

 
Older Posts →
Page 1 of 2

Archives

Categories

 
Subscribe!
Copyright © 2022 Hamid Mosalla
Casper Theme By Lacy Morrow