Package org.dbunit.dataset
Class DataSetBuilder
java.lang.Object
org.dbunit.dataset.DataSetBuilder
Fluent builder for creating
IDataSet instances programmatically,
reducing XML file dependencies in unit tests.
Single-table example:
IDataSet ds = new DataSetBuilder()
.table("FOO")
.columns("ID", "NAME")
.row(1, "Alice")
.row(2, "Bob")
.build();
Multi-table example:
IDataSet ds = new DataSetBuilder()
.table("FOO")
.columns("ID", "NAME")
.row(1, "Alice")
.table("BAR")
.columns("X")
.row(42)
.build();
- Since:
- 3.2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassFluent builder for a single table within aDataSetBuilder. -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
DataSetBuilder
public DataSetBuilder()
-
-
Method Details
-
table
Starts configuring a new table with the given name.- Parameters:
name- the table name- Returns:
- a
DataSetBuilder.TableBuilderfor configuring columns and rows
-
build
Builds and returns anIDataSetcontaining all configured tables.- Returns:
- the dataset
- Throws:
DataSetException- if any table configuration is invalid
-