/
executing-tmp.xml
166 lines (124 loc) · 5.7 KB
/
executing-tmp.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "../tck.ent">
%BOOK_ENTITIES;
]>
<chapter id="executing-test-harness">
<title>Executing a Test Suite</title>
<para>This chapter explains how to execute and debug a test suite built
using the JBoss Test Harness.</para>
<section id="test-suite-runner">
<title>Building a test suite runner using Maven 2</title>
<para>The test suite runner project is the magic that makes everything
come together and allows you to execute the test suite. If you fully
understand how the JBoss Test Harness functions, and have a good grasp on
Maven 2, then it's not to difficult to understand how the test suite
runner project works. Regardless of your background, this guide covers
what you need to know to get up and running by studying the test suite
runner used to run the Bean Validation TCK against the Bean Validation RI,
Hibernate Validator.</para>
<para>The TCK runner for the Hibernate Validator can be found in the
<filename>hibernate-validator-tck-runner</filename> directory in the
Hibernate Validator checkout. The dependencies of the TCK runner project
for Hibernate Validator are listed in <xref
linkend="tck-runner-dependencies" />.</para>
<table frame="all" id="tck-runner-dependencies"
title="CDI TCK Runner dependencies">
<title>Bean Validation TCK Runner Dependencies</title>
<tgroup cols="3">
<colspec colname="c1" />
<colspec colname="c2" />
<colspec colname="c3" />
<thead>
<row>
<entry>Group ID</entry>
<entry>Artifact ID</entry>
<entry>Version</entry>
</row>
</thead>
<tbody>
<row>
<entry>javax.validation</entry>
<entry>validation-api</entry>
<entry>&validationApi;</entry>
</row>
<row>
<entry>org.hibernate</entry>
<entry>hibernate-validator</entry>
<entry>&referenceImplVersion;</entry>
</row>
<row>
<entry>org.hibernate.beanvalidation.tck</entry>
<entry>jsr303-tck</entry>
<entry>&version;</entry>
</row>
<row>
<entry>org.hibernate.javax.persistence</entry>
<entry>hibernate-jpa-2.0-api</entry>
<entry>1.0.1.Final</entry>
</row>
<row>
<entry>org.sl4j</entry>
<entry>slf4j-api, slf4j-simple</entry>
<entry>1.6.1</entry>
</row>
<row>
<entry>org.testng</entry>
<entry>testng (classifier: jdk15)</entry>
<entry>5.8</entry>
</row>
<row>
<entry>org.jboss.jbossas.as7-cdi-tck</entry>
<entry>jbossas-container</entry>
<entry>1.0.0.Alpha1</entry>
</row>
</tbody>
</tgroup>
</table>
<para>You can find all of these artifacts in the <ulink
url="http://repository.jboss.org/maven2">JBoss Maven
repository</ulink>.</para>
<para>You should substituate the hibernate-validator artifact from <xref
linkend="tck-runner-dependencies" /> with your own artifact. You'll also
need to replace the jbossas-container artifact if you are not testing your
implementation on JBoss AS. The jbossas-container artifact contains
implementations of the <literal>Containers</literal> SPI for the JBoss
Test Harness for JBoss AS 7.</para>
<note>
<para>When running the test suite in the in-container mode, the tests
will run against libraries installed into the container.</para>
</note>
<para>The TCK is executed using the Maven TestNG plugin. Maven 2 profiles
are used to control the properties that are set at the time of the
execution. For instance, the <literal>incontainer</literal> profile
enables integration tests and disables standalone mode, changing the
default settings.</para>
</section>
<section id="dumping-test-artifacts">
<title>Dumping the Test Artifacts to Disk</title>
<para>As you have learned, when the test suite is executing using
in-container mode, each test class is packaged as a deployable artifact
and deployed to the container. The test is then executed within the
context of the deployed application. This leaves room for errors in
packaging. When investigating a test failure, it's helpful to be able to
inspect the artifact after it is generated. The JBoss Test Harness can
accommodate this type of inspection by "dumping" the generated artifact to
disk.</para>
<para>If you want to write the artifacts to disk, and avoid executing the
test suite, you can simply execute the main method of the class
<literal>org.jboss.testharness.api.TCK</literal>. For example you could
use a Maven profile that is activated when the
<literal>dumpArtifacts</literal> command line property is defined:</para>
<programlisting>mvn test-compile -DdumpArtifacts</programlisting>
<para>The output directory where the artifacts are written is defined by
the property
<literal>org.jboss.testharness.outputDirectory</literal>.</para>
<para>Once the artifact is written to disk, you have an option of manually
deploying it to the container. You can execute the tests in the artfact by
requesting the context path of the application in the browser. If you want
to execute an individual test method, specify the method name in the
<literal>methodName</literal> request parameter (e.g.,
?methodName=testMethodName).</para>
</section>
</chapter>