0

Examples of iText7 on http://developers.itextpdf.com use classes like com.itextpdf.test.annotations.WrapToTest (see e.g. http://developers.itextpdf.com/content/itext-7-jump-start-tutorial/examples/chapter-1).

/*
 * This example is part of the iText 7 tutorial.
 */
package tutorial.chapter01;

***SNIP IMPORTS***

/**
 * Simple Hello World example.
 */
@WrapToTest
public class C01E01_HelloWorld {
    ***SNIP CODE***
}

See also import of class com.itextpdf.test.annotations.type.SampleTest in http://developers.itextpdf.com/examples/actions-and-annotations/clone-adding-links-existing-documents.

/*

    This file is part of the iText (R) project.
    Copyright (c) 1998-2016 iText Group NV

*/

/**
 * This example was written by Bruno Lowagie in answer to the following question:
 * http://stackoverflow.com/questions/26983703/itext-how-to-stamp-image-on-existing-pdf-and-create-an-anchor
 */
package com.itextpdf.samples.sandbox.annotations;

***SNIP IMPORTS***

@Category(SampleTest.class)
public class AddImageLink extends GenericTest {
    ***SNIP CODE***
}

What are the com.itextpdf.test.**-classes used for?

Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
rpf
  • 31
  • 1
  • Welcome to SO. Please have a look at [the tour](http://stackoverflow.com/tour). You may also want to check [What topics can I ask about](http://stackoverflow.com/help/on-topic), and [How to ask a good question](http://stackoverflow.com/help/how-to-ask), and [The perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/), and how to create a [Minimal, Complete and Verifiable example](http://stackoverflow.com/help/mcve). Post the code you have tried and the errors you have received. Be as specific as possible as it will lead to better answers. – José Luis Nov 15 '16 at 13:49
  • ^ I'd say that 2 out of their 3 questions are actually acceptable questions for Stack Overflow. The third question, for the download location of iText source code, is indeed off topic. – Amedee Van Gasse Nov 15 '16 at 14:21

1 Answers1

3
  1. The code snippets you find on http://developers.itextpdf.com serve 2 purposes: they are examples that are used in the iText documentation, and they are also JUnit integration tests. To avoid writing all the JUnit boilerplate, we turned it into an annotation. If you look at the JavaDoc of the WrapToTest annotation: https://github.com/itext/itext7/blob/develop/pdftest/src/main/java/com/itextpdf/test/annotations/WrapToTest.java
    /**
     * This annotation can be used to run a class that contains a public
     * static void main method as a test in the JUnit test runner.
     */
  1. The annotations com.itextpdf.test.annotations.type.* might be deprecated in one of the next releases. They are only used to tell Maven which types of tests are unit tests and which are integration tests. Name-based separation of unit tests and integration tests is something I'm looking into. There is no time frame planned for this change. You definitely won't need them for your production code.

All iText source code can be found on GitHub, so you can check for yourself what it's used for: https://github.com/itext

Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101