Authenticating Api Gateway using Github Login

Many of us use third party identity providers (Facebook, Google, Github, Twitter)to identify our user. With OAuth2 and now OIDC it is easier than ever to provide authentication capabilities to the…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Writing Independent Tests

A lot of code uses environment variables, and we shouldn’t stop using environment variables just to make testing easier. So how can we test code that uses environment variables? One way could be to create a class with a method to get environment variables and then mock that method to return values that we want. Another way of testing code that uses environment variables is to use a config file. For example in src/main/resources you can put a file called application.conf with the following contents

Then for testing purposes you can put another file called application.conf in src/test/resources with the following contents

One example of a test which is dependent upon an internet connection is a test of code that tries to create a connection to a database. Such code could be tested using an in-memory database such as H2.

I hope that you have learned something useful. Feel free to leave a comment with feedback or your own experiences with testing.

Add a comment

Related posts:

Amazon Disruption

What started with just selling books online is now a multi-billion dollar company that offers products and services that span across multiple industries. In the process of Amazon’s development, they…

Single Serving Microwave Bean Brownie

I had a craving for bean brownies this morning, but I didn’t really feel like waiting around for them to bake. Microwave to the rescue! My food processor isn’t terrific, so you can see little bits of…

Time for sales to call a truce with customers

The old way of selling is over and here are the four new skills that salespeople need to learn.