question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please provide a method like ValidateConfiguration() for tests

See original GitHub issue

There’s nothing in the documentation about validating a container. I want a guarantee under test that for all the dependencies the container knows about, you would not receive a configuration error.

This is the best thing I can find, courtesy of @mikehadlow:

private static void CheckForPotentiallyMisconfiguredComponents(IWindsorContainer container)
{
    var host = (IDiagnosticsHost)container.Kernel.GetSubSystem(SubSystemConstants.DiagnosticsKey);
    var diagnostics = host.GetDiagnostic<IPotentiallyMisconfiguredComponentsDiagnostic>();

    var handlers = diagnostics.Inspect();

    if (handlers.Any())
    {
        var message = new StringBuilder();
        var inspector = new DependencyInspector(message);

        foreach (IExposeDependencyInfo handler in handlers)
        {
            handler.ObtainDependencyDetails(inspector);
        }

        throw new MisconfiguredComponentException(message.ToString());
    }
}

There’s nothing obvious about this code. If it is indeed the code you’re recommend, please ship the code as a ValidateConfiguration().

I’m surprised that such a test isn’t recommended practice for every user. This is something I’d expect to find conspicuously linked from both the readme and the FAQ. This is the closest thing I could find. It talks about testing various aspects of certain registrations but does not mention validating registrations to check specifically that all dependencies can be satisfied: https://github.com/castleproject/Windsor/blob/master/docs/mvc-tutorial-part-3a-testing-your-first-installer.md

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:51 (30 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Sep 13, 2017

And obligatory “excuse the mess” while I’m in the middle of sorting out what’s going on in there. Happy to explain what made me write a certain part.

Ha ha, no worries! I have baked your code in and can see the 3 failing tests. Going to sign off for tonight and pick this up first thing tomorrow.

0reactions
jnm2commented, Oct 9, 2017

Absolutely, that sounds good. I’m catching up on my backlog, so don’t let me hold you back.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to test validation annotations of a class using JUnit?
Here my way to unit test my objects with fields annotated with some javax.validation.constraints constraints. I will give an example with Java 8 ......
Read more >
Unit Testing and Coding: Why Testable Code Matters
To fully unit test the ActuateLights(bool motionDetected) method, we should perform interaction-based testing in addition to the state-based testing; that is, ...
Read more >
What is the Difference Between Test and Validation ...
Validation Dataset: The sample of data used to provide an unbiased evaluation of a model fit on the training dataset while tuning model ......
Read more >
Best practices for writing unit tests - .NET
Validate private methods by unit testing public methods ... In most cases, there shouldn't be a need to test a private method. Private...
Read more >
Java Unit Testing with JUnit and TestNG
Inside the test method, we can use static methods assertXxx() (in class org.unit.Assert ) to assert the expected and actual test outcomes, such...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found