I am a new lead developer that has recently started at a new company, I have been assigned to a project that is trying to consolidate functionality from lots of different applications already in widespread use in the business.

The problem is that their software development/project management are in the dark ages. I have committed myself to trying to improve things, starting off with automated builds, which is almost setup.

The next thing I Would like to add is automated testing. The issue I am facing with this is while the project is technically 'new' for the business the code that has already been written has a lot of dependencies and is considered(not by me) to be un-testable.

I have some experience in using the fakes framework to write unit tests for code with a lot of dependencies and i think we could use it to overcome the problems we face however are the project is being built around a large piece of middle-ware that contains the vast majority of the business logic and controls the data access. We are mostly just producing input for this system in a lot of cases.

So I am confused on what should actually be tested in this scenario or even how it could be done. It is a very large dependency which IMO is too big to mock or fake, so i cannot see a way to even validate the created input to what would be valid output.

  • 1
    What is the question? – JacquesB May 2 '17 at 8:58
  • 1
    it sounds like you know how to do it, but you're balking at the amount of work involved :) you are probably going to have to stub everything. I feel pity. I've been there myself. – Richard May 2 '17 at 9:27
  • 1
    I would not try to mock or fake something very large, but rather, focus on integration testing, and fixing the most critical low-level components to they can be unit tested (most likely without the need to mock). Start at the bottom most abstraction layer. – Frank Hileman May 2 '17 at 22:28
  • 1
    The problem with your question is, it is so general the only recommendation we can give you is to read a book on how to make software more testable. Fortunately, there is such a book: Working Effectively with Legacy Code. However, I am voting your question to close as "too broad". – Doc Brown May 20 '17 at 7:16

A large piece of middle-ware that contains the vast majority of the business logic and controls the data access

If you know the data source, you can start from there. If it is basically doing CRUD operations behind the scenes, you can test those by querying the database, running the tests, then querying the database again to compare the results before running the tests to the results after running the tests.



What exactly do you want to test?

How to test functionality that only creates input to a large middle-ware dependency

If you know the behaviour of the middleware, you could codify the behaviour into unit tests:

  • If I enter this data, it is going to be accepted.

  • If I enter that data, the middleware is going to choke on it

This is basically testing: evaluating whether the results match the expectations.

If you do not know the middleware's behaviour, study it:

  • Look what goes typically over the wire and take notes about what happens

  • Modify data, push it into the middleware and take notes about what happens

Make hypotheses and try to falsificate them.

This is the core of the scientific method: experimentation.

Each result could be turned into tests for your application. And step by step you improve.

Additionally: Reading the book @Doc Brown mentioned is recommended.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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