I have been searching for some unit tests for the program iText with no luck. Is anyone aware of any such tests? Also, does anyone know if the developers use any automatic testing tools on iText, such as Jenkins?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Internally, we use Jenkins as well as TeamCity.
We have two types of tests:
- The tests that are added when new core functionality is added, you can find them where Maven expects them: each Maven project has a
src
directory with 2 sub directories:main
andtest
. For instance: if you look at iText core, you'll find the released stuff here and the tests here. Most of these tests are built on top of our testutils. - The tests that are added when we get questions on SO or when we create code samples for the books. For these we use a generic test classes such as GenericTest and SandboxSampleWrapper. The wrapper class makes creating a test a no-brainer. All you need to do to turn a sample into a test is adding the
@WrapToTest
annotation. Well, actually there's more involved: you need to follow a specific pattern when writing a sample: always useSRC
andDEST
for source PDFs and resulting PDFs, always use acreatePdf()
ormanipulatePdf()
method, and always give the cmp file the same name as theDEST
file prefixed withcmp_
.
In both cases, you'll find PDF files of which the name starts with cmp_
, see for instance the cmpfiles folder for the examples. In both cases, you'll find references to Ghostscript and a compare tool (you'll need to configure these).