fitnesse-jdbc-slim
![Maven Central](https://camo.githubusercontent.com/b3c3019ad9d1f7ddded72b02e6df73bda209854ecd2fcc20d22b81cb0f874afe/68747470733a2f2f6d6176656e2d6261646765732e6865726f6b756170702e636f6d2f6d6176656e2d63656e7472616c2f636f6d2e6769746875622e616e6472657074622f6669746e657373652d6a6462632d736c696d2f62616467652e737667)
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.