1 /*
2 *
3 * The DbUnit Database Testing Framework
4 * Copyright (C)2002-2008, DbUnit.org
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21 package org.dbunit;
22
23 import org.dbunit.dataset.IDataSet;
24
25 /**
26 * Test case supporting prep data and expected data.
27 *
28 * @author Jeff Jensen jeffjensen AT users.sourceforge.net
29 * @author Last changed by: $Author$
30 * @version $Revision$ $Date$
31 * @since 2.4.8
32 */
33 public interface PrepAndExpectedTestCase {
34 /**
35 * Configure the test. Call this method before performing the test steps.
36 *
37 * @param tables
38 * Table definitions to verify after test execution.
39 * @param prepDataFiles
40 * The prep data files to load as seed data.
41 * @param expectedDataFiles
42 * The expected data files to load as expected data.
43 * @throws Exception
44 */
45 void configureTest(VerifyTableDefinition[] tables, String[] prepDataFiles,
46 String[] expectedDataFiles) throws Exception;
47
48 /**
49 * Execute pre-test steps. Call this method before performing the test
50 * steps.
51 *
52 * @throws Exception
53 */
54 void preTest() throws Exception;
55
56 /**
57 * Convenience method to call configureTest() and preTest().
58 *
59 * @param tables
60 * Table definitions to verify after test execution.
61 * @param prepDataFiles
62 * The prep data files to load as seed data.
63 * @param expectedDataFiles
64 * The expected data files to load as expected data.
65 * @throws Exception
66 */
67 void preTest(VerifyTableDefinition[] tables, String[] prepDataFiles,
68 String[] expectedDataFiles) throws Exception;
69
70 /**
71 * Execute all post-test steps. Call this method after performing the test
72 * steps.
73 *
74 * @throws Exception
75 */
76 void postTest() throws Exception;
77
78 /**
79 * Execute post-test steps. Call this method after performing the test
80 * steps.
81 *
82 * @param verifyData
83 * Specify true to perform verify data steps, false to not.
84 * Useful to specify false when test has failure in progress
85 * (e.g. an exception) and verifying data would fail, masking
86 * original test failure.
87 * @throws Exception
88 */
89 void postTest(boolean verifyData) throws Exception;
90
91 /**
92 * Cleanup tables specified in prep and expected datasets, using the
93 * provided databaseTester. See
94 * {@link org.dbunit.IDatabaseTester#onTearDown()}.
95 *
96 * @throws Exception
97 */
98 void cleanupData() throws Exception;
99
100 /**
101 * Get the prep dataset, created from the prepDataFiles.
102 *
103 * @return The prep dataset.
104 */
105 IDataSet getPrepDataset();
106
107 /**
108 * Get the expected dataset, created from the expectedDataFiles.
109 *
110 * @return The expected dataset.
111 */
112 IDataSet getExpectedDataset();
113 }