Don't miss out Virtual Happy Hour today (April 26).

Try our conversational search powered by Generative AI!

Stefan Forsberg
Nov 15, 2010
  4055
(3 votes)

Making EPiServer code testable – the role of the community

As I mentioned briefly in my last post I don’t think EPiServer have been under a lot of pressure from the community to make the core product (unit) testable. And while it would be nice if this was top of the priority list at the development team it’s not very realistic. Given that this series of posts will focus on what can be done today and hopefully raise some awareness so that more people bug Epi about this topic.

Joel Abrahamsson, while most known for his absolutely despicable taste in choice of radio stations, has create a few frameworks under the umbrella of EPiAbstractions that makes testing easier. Inspired by this, I thought I ought to step up too and try to contribute something to the community. But first the disclaimer.

The Catch-22 of writing about unit testing

The big problem I find with writing about this topic is that there’s largely two groups of people. Those who knows about unit testing and how to apply it and those who don’t. It’s very easy to fall into the trap of writing something that says nothing new to those who already applies it and still seem totally alienating to those who don’t. To make it more interesting, many people who do understand testing see the test themselves as a bi-product of other means, like good architecture or as a way to drive the design.

Personally my view of tests have evolved from “something I must do because all the cool kids are doing it” via “omg, how can I test this httpcontext” followed by “ah, SOLID makes sense and how did I live without IoC-containers” to today where I view the test primarily as documentation and a driving force for my code.

My aim here is to just try and write something that I feel that I would have found useful or at least intriguing from around two and a half years back and forward. If you find it to your liking, great. Otherwise, sorry for wasting your time.

The plan

This is mostly just for me so that I know what I had originally planned as well as to put some pressure on me to actually write something.

1. A quick introduction to the tools we’re going to be using; NUnit, Moq and MSpec.

2. A discussion about different “patterns” and concrete tests to the fallback language method discussed in earlier posts.

3. Refactoring (some of) Fredrik Vigs extension library EPiCode.Extensions to be testable and also write tests for it.

4. A sample site written in EPiMVP and what the MVP pattern means for your testability. This will also be used for an introduction to web testing using Watin or Selenium.

Nov 15, 2010

Comments

Nov 15, 2010 04:45 PM

Absolutely superb idea Stefan. I'm really looking forward to your posts.

From what I know of the UK EPiServer community - most developers understand the need and benefits of unit testing but aren't up the stage where it is a habit to actually write the test before implementing any code. Largely this is because of the difficulties with writing robust and meaningful tests against the core EPiServer API.

Any light you can shed on this will be much appreciated.

Nov 15, 2010 09:18 PM

This is gonna be interesting. Looking forward to it as well.

Nov 16, 2010 11:58 AM

+1
Sounds really interesting.

Please login to comment.
Latest blogs
Azure AI Language – Extractive Summarisation in Optimizely CMS

In this article, I demonstrate how extractive summarisation, provided by the Azure AI Language platform, can be leveraged to produce a set of summa...

Anil Patel | Apr 26, 2024 | Syndicated blog

Optimizely Unit Testing Using CmsContentScaffolding Package

Introduction Unit tests shouldn't be created just for business logic, but also for the content and rules defined for content creation (available...

MilosR | Apr 26, 2024

Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog