Chuan Chuan Law

Software Automation | Continuous Integration | Continuous Delivery

How To Setup Json Log in Logback

In pom.xml, add the dependency <dependency> <groupId>net.logstash.logback</groupId> <artifactId>logstash-logback-encoder</artifactId> <version>4.6</version> </dependency> 2. In logback.xml, add the LogstashEncoder appender  <appender name=”JSON” class=”ch.qos.logback.core.rolling.RollingFileAppender”> //This is the JSON formatter <encoder class=”net.logstash.logback.encoder.LogstashEncoder” /> //This is where the JSON log will be produced <file>${catalina.base}/logs/webapp.log.json</file> //On a daily basis, the JSON logged will be rolled over <rollingPolicy class=”ch.qos.logback.core.rolling.TimeBasedRollingPolicy”> <fileNamePattern>${catalina.base}/logs/webapp.log.json.%d{yyyy-MM-dd}</fileNamePattern> //We only store […]

Pact – How To Set Up Provider In Play Framework

In build.sbt, import the plugin import SbtProviderPlugin.config ++ Seq( providers := Seq( ProviderConfig(name = “Provider”, port=49600, requestFilter = Some(request => request.addHeader(“Authorization”, “Bearer NTY5YjQwNGQtYjFkMi00N2UyLThiODgtYzQzNzBkNzlkMDQ5”) )).hasPactWith(ConsumerConfig(name = “TestConsumer”, pactFile = file(“spec/pacts/test-consumer.json”))) ) ) 2. In a Makefile, have the following task: run-provider: make run-app & \ sleep 60 sbt pactVerify Where run-app is another Makefile task […]

Pact – Asserting The Function To Test from App Level

In your consumer test class, instead of calling the “subject.methodToTest()”, For example: describe MethodToTest{ before do         AppleServiceClient.base_uri ‘localhost:1234’     end   subject { }   describe “get_an_apple” do     before do         apple_service.given(“an apple exists”).         upon_receiving(“a request for an apple”).         with(method: […]

How To Setup Pact Broker

Setting up Dockerized Pact Broker The easiest and fastest way to do this is via Dockerized Pact Broker. By following Step 1 to Step 4 in this document, you will be able to have a Dockerized Pact Broker linking to a Dockerized PSQL in your localhost within minutes! All you then need is to publish the JSON […]

Hello from New York!

G’day! I haven’t been blogging for a while. This is because I have been busy settling in the Big Apple! It was a big move and I have been very blessed to have the opportunity to explore the other side of the world. I look forward to continue sharing what I have learned here. 🙂 […]

Solving Peer Not Authenticated Issue for Maven repository on AWS

Below the problem I got while migrating the Jenkins slave jobs over to AWS:     The way I solve it is to get a copy of compiled dependencies on the AWS instance and build a AMI image out of it. So, the AWS instance will already have a copy of all needed dependencies, and […]

Getting Your Tests Into CI – Jenkins

Test automation is not complete without CI –  getting it running automatically on a build box. I will show how to get a Selenium test suite running on Jenkins which I have been using personally. I will assume you have already got Jenkins installed: 1. Click on New Item. Give the item a name and […]

Accessing Oracle Database From Test Suite

Good test suites need to be able to access direct the database. Below is how I do it with my test suite in Groovy in Gradle framework accessing a Oracle database: (1) Connect the database in your code class TestDB { static void main(String[] args) { def sql = Sql.newInstance(‘’, ‘username’, ‘password’, ‘oracle.jdbc.driver.OracleDriver’)   (2) […]

How To Replace Selenium With Integration Test

The trend and best practice in test automation is to move away from writing lots of functional test in Selenium. So, we want to try to replace high level Selenium test with Integration and Unit tests as much as possible. Pros of Integration test: Easier to write in comparison to Unit test (no need mocking) […]

Extending PACT Framework – Global Data Setup & Data Cleanup

In every testing framework we do data setup and clean up. Below is how I do it with Gradle framework: Global Data Setup Pact framework provides very good random test data generation with PactBodyBuilder. However, in some cases where our API involves data creation, we will need to remember the data we created, so we can […]

« Older posts

© 2016 Chuan Chuan Law

Theme by Anders NorenUp ↑