Bullying / testing the main object in my system

I was asked to work on changing a number of classes, which are the basis for the system we are working on. Each of the classes in question requires 5 to 10 different related objects, which themselves need the same number of objects.

Data is also extracted from several data sources, and the project uses EJB2, so when testing, I run without a container to pull the dependencies I need!

I am starting to overload this task. I tried unit testing with JUnit and Easymock, but as soon as I mock or ignore one thing, I think she needs more. Everything seems to be pretty closely related, so I reach level 3 or 4 with my stubs to prevent NullPointerExceptions.

Usually with this type of task I just made changes and tested when I was walking. But the shortest build cycle is about 10 minutes, and I like to code very short iterations between executions (probably because I'm not very confident in my ability to write flawless code).

Does anyone know a good strategy / workflow to get out of this quagmire?

+3
source share
3 answers

Do you think this sounds like this: your main problem is that the API you are working with is too closely related. If you have the ability to modify the API, it can be very useful to hide the direct dependencies of the interfaces so that you can cut off the dependency graph of the direct dependencies.

, -Mocking Container. , , . .NET, Java.

, xUnit Test Patterns.

.

+5

, , . , , .

, . , , Injection Dependency. DI, ctors, no-arg ctor, ( , ) ctor.

EJB2, , !

? , POJO , , - EJB-y.

+1

Java 1.5, JMock? 2. * .

1. * 1.3+ Java, , .

As for the strategy, my advice is to cover the interfaces. Even if you have a single implementation of this interface, always create an interface. They can be easily tricked and will allow you to untie much better when testing your code.

+1
source

Source: https://habr.com/ru/post/1719381/


All Articles