I face the following:
Verification in order failure
Wanted but not invoked:
commandExecutor.execute(
src/test/resources,
isNull(),
"pdflatex",
["-interaction=nonstopmode", "-synctex=1", "-src-specials", "-recorder", "-shell-escape", "-output-format=pdf", "test.tex"],
src/test/resources/test.pdf
);
-> at org.m2latex.core.LatexProcessorTest.verifyRunLatex(LatexProcessorTest.java:700)
Wanted anywhere AFTER following interaction:
commandExecutor.execute(
src/test/resources,
null,
"pdflatex",
["-interaction=nonstopmode", "-synctex=1", "-src-specials", "-recorder", "-shell-escape", "-output-format=pdf", "test.tex"],
src/test/resources/test.pdf
);
-> at org.m2latex.core.LatexProcessor.runLatex2dev(LatexProcessor.java:1304)
What I do not understand is, that Mockito seems to see something looking for me as really the same as wanted, but seemingly is not. What is the reason???
The code is as follows:
this.inOrderExec.verify(this.executor, atLeastOnce())
.execute(eq(WORKING_DIR),
isNull(),
eq(this.settings.getLatex2pdfCommand()),
eq(LatexProcessor.buildLatexArguments
(this.settings,
this.settings.getPdfViaDvi(),
this.texFile)),
eq(this.dviPdfFile));
I verified also: The code works if I write
verify(this.executor, atLeastOnce())
i.e. without ordering.
I can post more code if necessary, of course.
Update: it seems as if this problem occurs if and only if
I cannot remove the , atLeastOnce()
argument.
Maybe this is a valuable hint for someone out there....
Update:
I found out, that in a method either all verify's work with inOrder
like that:
this.inOrder.verify(this.fileUtils).matchInFile
or neither does.
Special case:
private void verifyConstrLatexMainDesc() {
// FIXME: doubling from mockConstrLatexMainDesc()
String[] suffixes = new String[] {
LatexProcessor.SUFFIX_VOID,
LatexProcessor.SUFFIX_PDF,
"."+this.settings.getPdfViaDvi().getLatexLanguage(),
LatexProcessor.SUFFIX_LOG,
LatexProcessor.SUFFIX_IDX,
LatexProcessor.SUFFIX_IND,
LatexProcessor.SUFFIX_ILG,
LatexProcessor.SUFFIX_GLS,
LatexProcessor.SUFFIX_GLO,
LatexProcessor.SUFFIX_GLG
};
for (int idx = 0; idx < suffixes.length; idx++) {
//this.inOrder.
//if (idx == 1 ||idx == 2) {continue;}
verify(this.fileUtils, atLeastOnce())
.replaceSuffix(this.texFile, suffixes[idx]);
}
}
Ok, I see that this works if indices 1 and 2 are left out.
Then one can also leave away atLeastOnce()
I suspect that the problem is that a new string is created, right?
or that in my case, two arguments are '.pdf'
The other methods which work only for atLeastOnce()
are so that they are invoked more than once.
Is this a valuable hint?