Are some logical paths inherently unstable?

I use TDD to manage the project that I am currently working on, and the results were pretty satisfactory. I ran into a problem (described here; still without a solution or any suggestions!) Where there are some aspects of a particular method that may not be able to be tested (as in my example ; in short, I want to be able to handle a ManagementException that has a specific ErrorCode - but it seems impossible to configure a test that throws a similar ManagementException).

So how to deal with it? Do we simply agree that some logical paths are uncheckable (because of the scope in which we operate or are limited in the currently available testing infrastructures)?

+4
source share
5 answers

Some projects cannot be tested ... especially those that do not have the ability to test as one of the design goals. Typically, TDDed projects do not fall into this category.

To answer your original question, I posted an answer that includes using reflection in a slot in the requested error code. However, this may not work in all situations and is not a general solution.

The trade-off is to make an effort to write the test, given that this piece of code is under automatic tests. If you think that the cost-benefit ratio is huge, and the probability of failure is minimal, you can write it as an exceptional manual test, comment to future developers and check it manually. I would say that this is pragmatic, if you spent 30-40 minutes on a couple of brain attempts by the developers trying to get him to pass the test, maybe you need to step back and review your strategy. Take a look at Michael Peer, β€œWork Effectively With Legacy Code,” for some suggestions to overcome the barriers to verification.

+2
source

I don’t think that you could say that something is logically inappropriate, but you will certainly find areas of the code in which the effort needed to verify them is better spent elsewhere.

+2
source

This is a big question, and one that I also recently examined.

So, firstly, I would not say that some logical paths are "unstable" - in most cases, it is probably very difficult to test using automatic unit testing. You could probably experience most of these problematic paths with some serious trials in harsh conditions.

Consider this - everything you can check can be considered running inside the virtual machine under your control, and you can (theoretically) simulate every aspect of your work to test your software. Regardless of whether this is practical for most applications, this is another question.

+1
source

I just tried to answer your original question (and came across in the middle of the world with someone else saying the same thing more concise, or at least most of them ;-). In any case, there are frameworks that are too tight (thanks to private and friends), and if you cannot use introspection to get around this (despite having done all the necessary spells), you just use the language it's too tight, and also the structure which is.

I would be surprised if this were on a common system that supports dynamic languages ​​(like .NET does now), such as IronRuby and IronPython - perhaps if C # does not allow you to overcome access restrictions through introspection, dynamic languages ​​can serve.

However, it is possible that the overall environment will be designed so poorly and so rigidly that it would be impossible to test individual things - although I am not entirely sure that this is the case in your current situation.

+1
source

Some things cannot be tested in an automatic unit test, because the language / structure / situation is simply not open to it. The way to deal with this is to minimize this area and keep it so simple that it is unlikely to become a source of errors or behavior changes later.

There are also more tests than just unit testing, and those areas (such as Acceptance testing, QA, etc.) are also not covered by unit testing.

0
source

All Articles