io.github.nblxa:turntables-mysql8

Turntables: MySQL integration tests

Лицензия

Лицензия

Категории

Категории

MySQL Данные Базы данных
Группа

Группа

io.github.nblxa
Идентификатор

Идентификатор

turntables-mysql8
Последняя версия

Последняя версия

0.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

io.github.nblxa:turntables-mysql8
Turntables: MySQL integration tests
Ссылка на сайт

Ссылка на сайт

http://github.com/nblxa/turntables

Скачать turntables-mysql8

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/io.github.nblxa/turntables-mysql8/ -->
<dependency>
    <groupId>io.github.nblxa</groupId>
    <artifactId>turntables-mysql8</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.nblxa/turntables-mysql8/
implementation 'io.github.nblxa:turntables-mysql8:0.1.0'
// https://jarcasting.com/artifacts/io.github.nblxa/turntables-mysql8/
implementation ("io.github.nblxa:turntables-mysql8:0.1.0")
'io.github.nblxa:turntables-mysql8:jar:0.1.0'
<dependency org="io.github.nblxa" name="turntables-mysql8" rev="0.1.0">
  <artifact name="turntables-mysql8" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.nblxa', module='turntables-mysql8', version='0.1.0')
)
libraryDependencies += "io.github.nblxa" % "turntables-mysql8" % "0.1.0"
[io.github.nblxa/turntables-mysql8 "0.1.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
io.github.nblxa : turntables-core jar 0.1.0

provided (2)

Идентификатор библиотеки Тип Версия
com.github.spotbugs : spotbugs-annotations jar 4.1.4
mysql : mysql-connector-java jar 8.0.22

Модули Проекта

Данный проект не имеет модулей.

Turntables

Maven Central CircleCI Coverage Status Quality Gate Status

Turntables enables developers to write test assertions for data in tables using a simple fluent interface.

IntelliJ diff in comparison mode

Assertion errors are shown in an IDE-friendly way. The screenshot above demonstrates how IntelliJ IDEA highlights the differences between the actual and expected tables in the sample test.

  @Test
  public void test() {
    Tab actual = Turntables.tab()
        .col("name").key("id")
        .row("Elise", 1)
        .row("Bob", 2);

    Turntables.assertThat(actual)
        .colMode(Settings.ColMode.MATCH_BY_NAME)
        .rowMode(Settings.RowMode.MATCH_BY_KEY)
        .matches()
        .key("id").col("name")
        .row(1, "Alice")
        .row(2, "Bob")
        .asExpected();
  }

JUnit support

Turntables integrates with JUnit to help developers set up initial test data in tables:

@Rule
public TestDataSource testDataSource = TestDataFactory.jdbc(
        "jdbc:mysql://localhost:3306/mydb", "testuser", "str0ngPA55word!");

@TestTable(name = "employees", cleanUpAction = CleanUpAction.DROP)
public Tab testTab = Turntables.tab()
  .col("id").col("name")
  .row(1, "Alice")
  .row(2, "Bob");

Use the table name in test methods to get its contents for assertions.

Tab actual = testDataSource.ingest("employees");

For a complete example with MySQL, see ITMySql.java.

For Oracle, see: ITOracle.java.

Difference to AssertJ-DB

Turntables's main power and difference from AssertJ-DB is the ability to match whole table contents at once using specific rules (e.g. match rows by key or match columns by name) and to present to the developer only the difference that matters for the assertion.

As a result, less code must be written for tests and it's easier to find bugs.

Maven

Turntables extends AssertJ and you'll need both dependencies.

<dependency>
  <groupId>io.github.nblxa</groupId>
  <artifactId>turntables-core</artifactId>
  <version>0.2.0</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>io.github.nblxa</groupId>
  <artifactId>turntables-mysql</artifactId>
  <version>0.2.0</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.assertj</groupId>
  <artifactId>assertj-core</artifactId>
  <version>3.18.1</version>
  <scope>test</scope>
</dependency>

The above example uses a MySQL 8 dependency. If you use Turntables with another JDBC database, see JDBC for additional dependencies.

Build

A quick build skipping integration tests:

./mvnw clean package

Integration tests use Docker.

The Oracle test is containerized using the image quillbuilduser/oracle-18-xe.

Image size is 13GB at the time of writing this, so it's advisable to download it beforehand.

Build with integration tests:

docker run --rm -itd --name oracle -p 1521:1521 quillbuilduser/oracle-18-xe
docker run --rm -itd --name mysql -e MYSQL_ROOT_PASSWORD=tiger -e MYSQL_DATABASE=testdb -p 3306:3306 mysql:8.0.22
( docker logs -f mysql & ) | grep -m1 'MY-010931'
( docker logs -f oracle & ) | grep -m1 'DATABASE IS READY TO USE!'
./mvnw clean verify || true
docker stop oracle 2>/dev/null || true
docker stop mysql 2>/dev/null || true

Версии библиотеки

Версия
0.1.0