Java – Test thymeleaf custom dialect with mockito

I recently wrote a custom dialect and a custom processor for thymeleaf to handle some custom tags and replace them with different tags in some cases, but I encountered a problem when writing tests for the processor:

Abstractprocessor class needs to be overridden

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

Method, this is the method I need to test

Since my processor involves getting variables from the arguments parameter, I try to simulate it; However, the arguments, processormatchingcontext and node classes are declared final, which means that they cannot be emulated by mockito

I really don't want to instantiate an actual arguments object because it depends on five other objects that can't be simulated. I will eventually write a lot of code to test a line in the processor

Any ideas about possible testing strategies?

Solution

I don't know if this helps, but you can instantiate an actual (non simulated) parameter using objenesis without all the other five dependent classes

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>