fitnesse-jdbc-slim
FitNesse JDBC fixture in slim format. Allows running SQL commands on multiple database connections. This project is licensed under MIT.
Installation
- This module and spring dependencies must be in FitNesse classpath. You can download the jar from here or with maven (see below).
- The jdbc driver which the fixture will be used to connect also must be on FitNesse classpath.
<dependency>
<groupId>com.github.andreptb</groupId>
<artifactId>fitnesse-jdbc-slim</artifactId>
<version>0.0.2</version>
</dependency>
Sample:
|import|
|com.github.andreptb.fitnesse|
|library|
|jdbc fixture|
|script|
|connect jdbc on | ${DATABASE_NAME} | with url | ${DATABASE_URL} | and driver | ${DRIVER_CLASS_NAME} | and username | ${DATABASE_USERNAME} | and password | ${DATABASE_PASSWORD} | # registers the ${DATABASE_NAME} database, must be the done before running SQL commands
|run in | ${DATABASE_NAME} | CREATE TABLE USER (ID BIGINT IDENTITY, NAME VARCHAR(255) NOT NULL, PASSWORD VARCHAR(255) NOT NULL) | # runs the command CREATE TABLE, only fails if an exception occurs.
|run in | ${DATABASE_NAME} | INSERT INTO USER (NAME, PASSWORD) VALUES ('user1', 'password1') | # runs the command INSERT, only fails if an exception occurs.
|$usernameId= | query in | ${DATABASE_NAME} | SELECT ID FROM USER WHERE NAME = 'user1' | # runs a SELECT command, assigns the value of the first column of the first row to the variable $usernameId. If was an UPDATE command, would return the updated rows count.