spring-boot with flyway and how to get your tests working

spring-boot with flyway and how to get your tests working published on No Comments on spring-boot with flyway and how to get your tests working

Problem You have a spring boot application with flyway migration scripts for a MySQL database. Now your tests are failing because you don’t have the database available during unit testing and flyway is complaining. Solution Use an in memory H2 database in MySql mode. How Create a file called flyway_init.sql in src/test/resources with the following… Continue reading spring-boot with flyway and how to get your tests working

How to create JUnit 4 tests with Weld

How to create JUnit 4 tests with Weld published on No Comments on How to create JUnit 4 tests with Weld

Problem You want to write a couple of Integration tests with JUnit and want to use Weld for the CDI part, but don’t know how… Solution Add Weld dependency to your maven project Weld dependency

Create a couple of helper classes: WeldContext

WeldJUnit4Runner

Initialize bean context for test by creating in the… Continue reading How to create JUnit 4 tests with Weld

Field Injection when Mocking frameworks fail

Field Injection when Mocking frameworks fail published on No Comments on Field Injection when Mocking frameworks fail

Also published on DZone Problem You use Dependency Injection (CDI) in your application and you want to unit test your Java classes without making it an integration test by using Weld of Arquillian. You use a Mocking framework like Mockito or EasyMock but still have trouble getting all your dependencies injected into the class because… Continue reading Field Injection when Mocking frameworks fail