5

I'm trying to unit test a TBB. To do that I have created a PageAdapter which has a Page (from Tridion) inside and the method I need and implements an interface IPage so it can be injected (both real and mocked one).

My problem is to create the mock of Page since it's saying I need to reference Tridion.ContentManager.Data and I don't have it nor I find it in the GAC.

Any idea?

1

1 Answer 1

4

It's tempting to see Tridion templating as an exercise in object-oriented programming, in which idiom the most obvious automated test is a unit-test. It's often better to see it as a data transformation. Then the most obvious testing idiom is to set up a known state in the package before the template executes, and afterwards to make assertions about the resulting state.

With this in mind, some of us created a framework that supports this kind of testing. You can find it here.

Even the T-Cubed framework is probably better suited to testing Component Template building blocks. For Page Templates, a good approach is to create test pages and assert against the output from the render. You can call Render directly from the API, or publish the page and test it using a web testing framework. If you use component presentations with known, recognisable output, it helps to keep your page tests simple.

1
  • Hi @dominic-croninc, thank for answering. I did see your framework, But unfortunately, when I try it (as it is) is asking me for Tridion.ContentManager.Data dll, which I was not able to find anywhere (not even in the GAC).
    – polonskyg
    Commented Jan 23, 2017 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.