Product: Ideas for easing Unit Testing

  1. Make pipeline arg objects pure POCOs

    Example: HttpRequestArgs has an internal Initialize method. This prevents the ability to instantiate a fully functional args object.

    16 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    0 comments  ·  Flag idea as inappropriate…  ·  Admin →
  2. Sitecore Configuration Factory should be an abstract class or interface

    As a static factory it's extremely difficult to then return or mock out things like GetDatabase or SiteContext, etc.

    13 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    2 comments  ·  Flag idea as inappropriate…  ·  Admin →
  3. Make SiteContext mockable

    SiteContext construction currently depends on a SiteInfo, which creates dependencies on logging and caches... so dependent on Sitecore config.

    12 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    2 comments  ·  Flag idea as inappropriate…  ·  Admin →
  4. Make all item fields abstract or "pure virtual" to support recursive mocks in NSubstitute

    Sitecore 8.2 makes creating NSubstitute items very useful, as all methods are virtual. However, because types like ItemPath and Field have non-virtual methods or have non-default construstors, it is not possible to use NSubstitute's recursive mock feature to do things like:

    subItem.Paths.FullPath.Returns("/sitecore/content/home");
    subItem.Fields["Some Field"].Value.Returns("some value");

    instead, it is necessary to do things like:
    subItem.Paths.Returns(Substitute.For<ItemPath>());
    subItem.Fields["Some Field"].Returns(Substitute.For<Field>(ID.NewID, subItem);

    By replacing these field types with abstract base classes, the friction of using Substitutes would be greatly reduced.

    See http://nsubstitute.github.io/help/auto-and-recursive-mocks/
    ("A pure virtual class is defined as one with all its public methods and properties defined as virtual or abstract and with a…

    7 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    2 comments  ·  Flag idea as inappropriate…  ·  Admin →
  5. Create Documentation on ways to test or isolate sitecore components

    A lot of this, and learning how to instantiate and create testable sitecore components, could be helped along by better documentation on how to mock or create sitecore components instead of poking around with ILSpy

    7 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    1 comment  ·  Flag idea as inappropriate…  ·  Admin →
  6. Make IQueryable Sitecore Search objects unit testable

    Sitecore search code is incredibly difficult if not impossible to unit test as I understand it right now. It in my opinion is also one of the most important areas in a Sitecore implementation.

    If it is actually testable, publicise it, if not - the ability to test a generated IQueryable would be just awesome.

    This might be as simple as a .ToString() that returns "Where the property {0} equals {1}" with appropriate values assigned. This in turn would generate a string that we as developers could assert.

    4 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    0 comments  ·  Flag idea as inappropriate…  ·  Admin →
  7. Create wrapper and interface for WebUtil

    All of the Util classes could use this, but I would start with WebUtil since it is probably the most widely used. It would be better in the long run to refactor the utility classes to adhere to the single responsibility principle, but adding wrappers and interfaces would be a lot easier.

    1 vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    0 comments  ·  Flag idea as inappropriate…  ·  Admin →
  • Don't see your idea?

Product: Ideas for easing Unit Testing

Categories

Feedback and Knowledge Base