Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Euan Rae 105 posts 135 karma points
    Jun 22, 2019 @ 10:52
    Euan Rae
    0

    Unit Testing Umbraco 8 with Our.Umbraco.Community.Tests

    I'm having issues trying to use the Umbraco unit tests to base my tests on. If I try to inherit from one of the base tests, e.g. Umbraco.Tests.Testing.UmbracoTestBase, I get the following exception:

    System.TypeLoadException: 'Could not load type 'MyLibrary.Umbraco8Source.Tests.MyTest' from assembly 'Umbraco.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.'

    It looks like this is because of the line:

    Options = TestOptionAttributeBase.GetTestOptions<UmbracoTestAttribute>();
    

    in UmbracoTestBase.Setup() that tries to load the test class from within the current Assembly (Umbraco.Tests)

    It doesn't look like we can inherit from any of the V8 tests; is there any way to do this?

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Feb 21, 2020 @ 14:18
    Ismail Mayat
    0

    Euan,

    I just got that, I did try decorating my test class with

    [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
    

    But still no joy. Now in v7 you have to ensure that the test was in namespace Umbraco.Tests because alot of umbraco internals had been marked as visible to Umbraco.Tests however in v8 does not look like that is the case.

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft