Testing an arbitrary dialect of Timeleaf with Mockito

I recently wrote a special dialect for Thymeleaf along with a custom processor to process some custom tags, and in some cases replaced them with different ones, but I had problems writing tests for the processor:

Class AbstractProcessorrequires overriding

protected ProcessorResult doProcess(Arguments arguments, ProcessorMatchingContext processorMatchingContext, Node node)

which I have to check.

Since my processor involves getting variables from a parameter arguments, I tried to taunt him; However, classes arguments, ProcessorMatchingContextand Nodewill announce the final, which means that they can not be the product Mockito.

I really don't want to instantiate the actual object arguments, since it depends on 5 other objects that cannot be mocked, and I would finish writing tons of code to test only one line in my processor.

Any ideas for a possible testing strategy?

+4
source share
2 answers

I donโ€™t know if this would help or not, but you can create an instance of the actual (non-mutable) arguments without all 5 other dependent classes using Objenesis

0
source

mockito.when().thenReturn() , , .

0

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


All Articles