91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Java中@Category注解的工作原理是什么

發布時間:2021-07-20 15:47:23 來源:億速云 閱讀:414 作者:Leah 欄目:編程語言

今天就跟大家聊聊有關Java中@Category注解的工作原理是什么,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。

(1) Create empty class FastTests and SlowTests. (2) In your test case class, categorize your test method using @Category annotation:

Java中@Category注解的工作原理是什么

(3) Append the following code to your pom.xml:

<profiles>
        <profile>
            <id>SlowTests</id>
            <properties>
                <testcase.groups>com.sap.SlowTests</testcase.groups>
            </properties>
        </profile>
        <profile>
            <id>FastTests</id>
            <properties>
                <testcase.groups>com.sap.FastTests</testcase.groups>
            </properties>
        </profile>
    </profiles>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.13</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit47</artifactId>
                        <version>2.13</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <groups>${testcase.groups}</groups>
                </configuration>
            </plugin>
        </plugins>
    </build>

(4) In my project, by default all 7 test methods will be executed during Maven build:

Java中@Category注解的工作原理是什么

Suppose you only want to execute unit test belonging to category “SlowTests”, use the following command line:

Java中@Category注解的工作原理是什么

Since now I only marked one method with annotation SlowTests, only one test method is executed:

Java中@Category注解的工作原理是什么

If you would like to execute all unit tests EXCEPT @SlowTests, simply add another profile in pom.xml:

<profile>
            <id>NonSlowTests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <excludedGroups>com.sap.SlowTests</excludedGroups>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

Before test, in order to prove that Slow method is NOT really executed, I add a system.out.println in each method:

Java中@Category注解的工作原理是什么

Use command line: mvn test -P NonSlowTests From console output, I can ensure that the method with @Category(SlowTests.class) is NOT executed at all.

Java中@Category注解的工作原理是什么

看完上述內容,你們對Java中@Category注解的工作原理是什么有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注億速云行業資訊頻道,感謝大家的支持。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

濉溪县| 盖州市| 蓝田县| 麻城市| 甘孜县| 五台县| 罗平县| 富顺县| 广丰县| 七台河市| 马边| 登封市| 利辛县| 辽中县| 华亭县| 双鸭山市| 通渭县| 文水县| 长汀县| 龙井市| 香格里拉县| 安仁县| 井陉县| 东港市| 莆田市| 井冈山市| 荣成市| 双峰县| 宜章县| 福安市| 洪江市| 漳平市| 双江| 大埔区| 务川| 韩城市| 扶绥县| 平顶山市| 海安县| 清涧县| 巨野县|