-
Notifications
You must be signed in to change notification settings - Fork 795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit testing documentation is wrong #1879
Comments
Oh no @DontPanic345 ! 😱 Which version of Umbraco are you running it on? |
Hi @sofietoft, thanks for the reply I'm using 7.15.1, and was having a lot of trouble getting my tests to run inside Visual Studio, used this page as a place to make my gripe. I think I have it figured out now by following https://github.com/lars-erik/umbraco-unit-testing-samples and coping the adapter class in there. This page could use a little something to say that it is for 8. But doesn't look like valid C# to me the |
Aah, good point @DontPanic345 ! Good to hear you managed to figure out how to run it in Umbraco 7! |
Ideally we should update these unit testing docs to show best practices examples. For the most part we don't want to be initializing singletons. In some cases this may be needed but that would generally only be for integration test. Unit testing is done on the premise of constructor injection which these examples do not showcase. I've written up an explanation of this here umbraco/Umbraco-CMS#6578 (comment) and followed up more here umbraco/Umbraco-CMS#6578 (comment) We have some great documentation about dependency injection hidden away in this article here https://our.umbraco.com/documentation/Implementation/Services/#custom-services-and-helpers-1 ... most of this information should be copied and/or migrated to the dependency injection docs here: https://our.umbraco.com/Documentation/Reference/Using-Ioc/ and also to the unit testing docs. For example, testing controllers should be using full constructor injection. The reason why this article says you will get an exception is purely because these things are being tested with their default constructors and not their full constructors which they should be. There's an example of ctor injection being done in the docs way down here https://our.umbraco.com/Documentation/Implementation/Unit-Testing/#dictionaries with the |
Hi @DontPanic345, We're writing to let you know that we've added the For more information about issues and states, have a look at this blog post Thanks muchly, from your friendly PR team bot :-) |
I'm working on a PR update for this page where all tests are using full constructor injection,
Should have this PR ready before the weekend or beginning of last week. |
That's fantastic @Adolfi 😄 🎉 Looking forward to review your work!! |
This issue could probably be closed now @sofietoft. |
Ah, I think you're right! 👌 Good catch @Adolfi 😁 |
This is the page with issues: https://github.com/umbraco/UmbracoDocs/edit/master/Implementation/Unit-Testing/index.md
This page is totally unhelpful
current
doesn't exist at all.The text was updated successfully, but these errors were encountered: