Русский English Tags View Sergey Zolotaryov's profile on LinkedIn Sign-in
Unit testing Google Storage code
Permanent link 13-12-2018 anydoby java google cloud

It's a bit of a hassle to test code that uses Google Storage. We have something for Datastore and Pubsub (an official emulator docker image from the big brother). However there's no hint of a Google Storage emulator yet. And since API's are all static it's a bit of a pain to write good mocks.

The JUnit Rule code is located here.

Usage is quite straightforward: include the rule to your test and use all the StorageOptions methods as if you were running in the cloud. Under the carpet there's a lot of PowerMock magic, so first study the README and rule's unit tests. The emulator is quite basic at the moment. If you like it and if you are missing functionality, give me a hint or add it yourself.

Happy testing.

Add a comment

Previous article Reporting Apache Ignite cache metrics with Micrometer and Spring Boot Next article Reporting progress from Java applications in console