Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Beyond DBUnit and Raw SQL: Type-Safe Database State in Java Tests

If you’ve spent any time writing integration tests in Java or Kotlin against real databases, you’ve likely hit one of these pain points: DBUnit XML/YAML fixtures that rot silently until column renames break CI. Hand-written SQL seeding scripts with zero autocomplete or compile-time safety. Overloaded JPA/Hibernate entities dragged into simple test setups just to insert two rows. Mocks hide…

The article discusses a new Java library called jdbscript that simplifies database seeding in integration tests. The library provides a type-safe alternative to using raw SQL or XML fixtures, which often lead to maintenance issues. jdbscript represents the database schema using plain Java or Kotlin interfaces, with dynamic proxies handling the underlying database operations.

To use jdbscript, users define their schema as an interface, and then create an engine that manipulates the database based on that interface. Test fixtures can be cleanly seeded using the `resetDB` method, which automatically cleans and inserts records in the correct order to avoid constraint violations. jdbscript also enables migration testing by verifying Flyway or Liquibase scripts against real schemas.

One of the key advantages of jdbscript is its flexibility and broad database support. It requires Java 17 or later and a standard DataSource, making it compatible with various databases such as PostgreSQL, MySQL, MariaDB, Oracle, SQL Server, Google Cloud Spanner, H2, CockroachDB, and DuckDB. The library integrates seamlessly with popular testing frameworks like JUnit 5, Testcontainers, and Spring Boot.

The article highlights that jdbscript is fully functional, with 12 runnable examples available at jdbscript.org. Users are encouraged to try jdbscript in their own testing workflows to see how it can improve the maintainability and reliability of their integration tests.

Rewritten by urgent.news; may contain errors — check the original.

Read the original at dev.to →

More in Tech

"Company Portal can't connect" / device not syncing — a 10-minute triage order for Intune admins

"Company Portal can't connect": a 10-minute triage order The ticket says "Company Portal can't connect" or "my laptop isn't getting the new policy." The tempting move is to start re-enrolling.

  • Company Portal not connecting, often resolved with Intune triage process
  • Check user scope, license, and MDM scope for Company Portal issues
  • Examine device status, MDM URL, and sync times to troubleshoot

Gomponents v1.4.0 Released: Performance Boosts and New Feature for Go HTML Component Library

Introduction Six years in the making, gomponents has solidified its place as a mature and efficient Go library for building HTML components without extra build steps.

  • Performance gains with memory usage optimization in gomponents v1.4.0
  • Computational overhead reduced through inlining and simplified control flow
  • Official coding agents skill introduced for enhanced developer workflows

More from Wednesday 7 October →