View Javadoc
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      /**
36       * Configure the test. Call this method before performing the test steps.
37       *
38       * @param verifyTables
39       *            Table definitions to verify after test execution.
40       * @param prepDataFiles
41       *            The prep data files to load as seed data.
42       * @param expectedDataFiles
43       *            The expected data files to load as expected data.
44       * @throws Exception
45       */
46      void configureTest(VerifyTableDefinition[] verifyTables,
47              String[] prepDataFiles, String[] expectedDataFiles)
48              throws Exception;
49  
50      /**
51       * Execute pre-test steps. Call this method before performing the test
52       * steps.
53       *
54       * @throws Exception
55       */
56      void preTest() throws Exception;
57  
58      /**
59       * Convenience method to call configureTest() and preTest().
60       *
61       * @param verifyTables
62       *            Table definitions to verify after test execution.
63       * @param prepDataFiles
64       *            The prep data files to load as seed data.
65       * @param expectedDataFiles
66       *            The expected data files to load as expected data.
67       * @throws Exception
68       */
69      void preTest(VerifyTableDefinition[] verifyTables, String[] prepDataFiles,
70              String[] expectedDataFiles) throws Exception;
71  
72      /**
73       * Run the DbUnit test.
74       *
75       * @param verifyTables
76       *            Table definitions to verify after test execution.
77       * @param prepDataFiles
78       *            The prep data files to load as seed data.
79       * @param expectedDataFiles
80       *            The expected data files to load as expected data.
81       * @param testSteps
82       *            The test steps to run.
83       * @return User defined object from running the test steps.
84       * @throws Exception
85       * @since 2.5.2
86       */
87      Object runTest(VerifyTableDefinition[] verifyTables, String[] prepDataFiles,
88              String[] expectedDataFiles, PrepAndExpectedTestCaseSteps testSteps)
89              throws Exception;
90  
91      /**
92       * Execute all post-test steps. Call this method after performing the test
93       * steps.
94       *
95       * @throws Exception
96       */
97      void postTest() throws Exception;
98  
99      /**
100      * Execute post-test steps. Call this method after performing the test
101      * steps.
102      *
103      * @param verifyData
104      *            Specify true to perform verify data steps, false to not.
105      *            Useful to specify false when test has failure in progress
106      *            (e.g. an exception) and verifying data would fail, masking
107      *            original test failure.
108      * @throws Exception
109      */
110     void postTest(boolean verifyData) throws Exception;
111 
112     /**
113      * For the provided VerifyTableDefinitions, verify each table's actual
114      * results are as expected.
115      *
116      * @throws Exception
117      */
118     void verifyData() throws Exception;
119 
120     /**
121      * Cleanup tables specified in prep and expected datasets, using the
122      * provided databaseTester. See
123      * {@link org.dbunit.IDatabaseTester#onTearDown()}.
124      *
125      * @throws Exception
126      */
127     void cleanupData() throws Exception;
128 
129     /**
130      * Get the prep dataset, created from the prepDataFiles.
131      *
132      * @return The prep dataset.
133      */
134     IDataSet getPrepDataset();
135 
136     /**
137      * Get the expected dataset, created from the expectedDataFiles.
138      *
139      * @return The expected dataset.
140      */
141     IDataSet getExpectedDataset();
142 }