Aug 19
2022

By Eugene Paden

Unit Testing Kentico Xperience 13 with XUnit

5 Reasons Why Your Company Should Use an ERP System

I don't write much and I do not definitely do blogs. But I do write code. And I write tests for code. So when .Net Core became a development model for Kentico Xperience 13, it became a perfect time to have start full unit tests on our code.

I also decided that I will create a series of articles on unit testing Kentico Xperience projects as most of the articles I have looked at covered mostly the basics not an in-depth look of how to fully cover a project with tests.

I reached out to Kentico and shared with them my plan to do the unit testing article series using the MedioClinic Sample Site . The sample project is featured in the Kentico Xperience Training modules. Fortunately, they concurred and here we are.

What to expect from this series? Well, I will be starting with simple unit tests, all the way to having at least 80% code coverage for the whole project. Of course, I will also share the tools used and full source code.

Let's start with the tools first.

  • Azure DevOps - Project management, source control and CI/CD:
  • Visual Studio 2022  - IDE
  • SonarCloud  - Static Code Analysis, Code Coverage
  • xUnit  - Testing framework/platform instead of NUnit used and supported by the Kentico Xperience Test Libraries.
  • AutoFac.AutoMock  - Auto mocking library to automatically create mock dependencies for both concrete and mock abstract instances in unit tests
  • AutoFixture  - for automatically creating test fixtures without hand-coding variables
Also listing below some of the articles specific to unit testing in Kentico
 

Articles in This Series

  • 1 - Setting up the Test Project and Writing Our First Test (xUnit, AutoFixture, Kentico Fake)
  • Upcoming: 2 - Introduction to Mocking (Moq)
  • Upcoming: 3 - Introduction to AutoMock (AutoFac.AutoMock)
  • Upcoming: 4 - More xUnit Asserts (Null, Empty, Throws, ThrowsAsync, IsType, Single)
  • Upcoming: 5 - More Complex Mocks and Tests (Async Mock, Fakes)
  • Upcoming: 6 - Major Test Milestone, Testing BasePageRepository
  • Upcoming: 7 - Getting to 90% Code Coverage of XperienceAdapter
  • Upcoming: 8 - Setting up the MedioClinic Site Test Project (ViewComponent Testing)
  • Upcoming: 9 - Testing FormComponents
  • Upcoming: 10 - Testing Controllers
  • Upcoming: 11 - Testing Middleware
  • Upcoming: 12 - Testing Startup
  • Upcoming: 13 - Testing Pages using WebApplicationFactory
Please post all your Questions here
 

About Author:

Eugene Paden

Eugene Paden is the CTO of Ray Business Technologies. He is a Kentico Certified Developer, Certified Boomi Professional Developer and Architect. He has over 25 years of technology experience and has been creating, delivering and implementing business transformation solutions deeply aligned with business strategies and objectives.

Author's Kentico DevNet Profile

Contact the Author:
- My ASP.NET Application
We use cookies to provide the best possible browsing experience to you. By continuing to use our website, you agree to our Cookie Policy