2016-11-15 57 views
0

http://developers.itextpdf.com上的iText7的示例使用諸如com.itextpdf.test.annotations.WrapToTest (例如參見http://developers.itextpdf.com/content/itext-7-jump-start-tutorial/examples/chapter-1)的類。什麼是com.itextpdf.test。** - 用於什麼類?

/* 
* 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*** 
} 

又見com.itextpdf.test.annotations.type.SampleTest類的進口在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*** 
} 

用於什麼com.itextpdf.test.** - 班?

+0

歡迎SO。請看[旅遊](http://stackoverflow.com/tour)。您可能還想檢查[我可以詢問哪些主題](http://stackoverflow.com/help/on-topic)以​​及[如何提出一個好問題](http://stackoverflow.com/help/)如何提問)和[完美問題](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/),以及如何創建[最小,完整和可驗證示例](http://stackoverflow.com/help/mcve)。發佈您嘗試過的代碼以及收到的錯誤。儘可能具體,因爲它會導致更好的答案。 –

+0

^我想說,他們的3個問題中的2個是Stack Overflow的實際可接受的問題。第三個問題,關於iText源代碼的下載位置,確實是一個非主題。 –

回答

3
  1. http://developers.itextpdf.com找到的代碼片段起到2個用途:它們是在該iText的文檔中使用的例子,他們也JUnit的集成測試。爲了避免編寫所有的JUnit樣板,我們將其轉換爲註釋。 如果你看一下WrapToTest註釋的JavaDoc: 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. 
    */ 
  • 註解com.itextpdf.test.annotations.type.*可能在未來的版本中的一個被廢棄。它們僅用於告訴Maven哪些類型的測試是單元測試,哪些是集成測試。基於名稱的單元測試和集成測試分離是我正在研究的內容。沒有時間框架計劃這個變化。你絕對不會需要它們用於你的生產代碼。
  • 所有iText的源代碼可以在GitHub上找到,所以就是它的使用,你可以自行覈實:https://github.com/itext