Design Insights From Unit Testing

Probably the biggest breakthrough while Unit Testing is to realize that writing tests offer priceless feedback about the design of your production code. This feedback goes from suggesting immediate obvious improvements, up to hints about some of the most advanced design principles in software engineering. This article briefly enumerates these hints, pointing to questions to ask about your design. 

Disclaimer: Don't follow blindly these hints, but make sure you understand all of them so that you can decide in your real problem what would improve the design, and what wouldn't.

Connect to a Database Instance Running Inside a Java Testcontainer Using IntelliJ IDEA

JUnit is one of the most popular unit testing frameworks used with Java to create repeatable tests. With JUnit, each test is written as a separate method inside a Java class. IntelliJ IDEA provides an option to run these test cases from within the IDE.

In case you have a module that communicates with a MySQL database, you can unit test the module by providing it access to a MySQL server running inside a Testcontainer. You can also configure this MySQL database instance with your desired username, password, and database name (in MySQL server) using the API provided by the Testcontainers framework.

Fluent Assertions Reloaded

If you’re not using fluent assertions in your tests yet and just rely on basic JUnit assertions, you might be missing out on a simple but very effective tool to write high-quality test code. The article starts with a short recap about the virtues of fluent assertions and how they address the shortcomings of basic assertions.

But while very much in favor of fluent assertion I think that current implementations don’t realize their full power: Problems are demonstrated in AssertJ, the main fluent assertion library for Java. Finally, I present a new solution to overcome these issues.

7 Easy Steps to Generate Both XML and HTML Reports in Cypress

The common requirement when we are working with automation tests in we need to generate both XML and HMTL reports. When it comes to Cypress it relies on Mochawesome reporter. In this article, I will explain to you a simple way to generate HTML and Junit XML reporter in your Cypress end-to-end Automation framework. 

If you look over the internet there are many articles but for beginners, it's very complicated Since there is some complexity involved. 

How To Run JUnit Tests From The Command Line

JUnit is one of the most popular Java-based open-source frameworks used for testing every unit of the application, i.e., classes and methods. And for automating the testing of web applications, you can use it with the Selenium WebDriver. Though Selenium and JUnit can function independently, combining them can help develop tests in a structured format.

Though Java offers several IDEs using which you can write code and run tests, you would like to execute JUnit from the command line. Why?

Parallel RSpec Tests on CircleCI With JUnit XML Reports

You will learn how to run RSpec tests for your Ruby on Rails project on CircleCI with parallel jobs to shorten the running time of your CI build. Moreover, you will learn how to configure JUnit formatter to generate an XML report for your tests to show failing RSpec test examples nicely in CircleCI web UI. Finally, you will see how to automatically detect slow spec files and divide their test examples between parallel jobs to eliminate the bottleneck job that’s taking too much time to run tests.

Ruby Gems to Configure Your RoR Project

Here are the key elements you need:

Unit Testing Void Methods with Mockito and JUnit

Writing functionality is the main focus whenever we are writing a software program, but it is equally important that we make sure our code works the way we intended it to. And how do we do that? By writing unit test cases. They are used to test the smallest functionality of code. Unit test cases are an essential part of software development. In this blog, we are going to cover one of the testing scenarios and unit test cases for void methods.

How to Test Void Methods 

As we already know that our aim is to test void methods in a class. But it is also really important to understand why we test void methods. 

JUnit Test Groups for More Reliable Development

Introduction

As a product is being developed and maintained its test suite is enriched as features and functionalities are added and enhanced. Ideally, development teams should aim having a lot of quick unit tests that are run whenever modifications in the code are made. It is great if these are written before or at least together with the tested code, cover as many use cases as possible and finish running after a reasonable amount of time. By all means, a reasonable amount of time is an entity difficult to quantify. 

On the other hand, there are a lot of live products that solve quite complex business problems whose thorough verification concerns cross-cutting through multiple application layers at once and thus, the number of integration tests is significant. Running all these unit and integration tests whenever the code is touched is not always feasible, as the productivity and the development speed is decreased considerably. Again, productivity and development speed are hard to quantify but should be always traded for correctness. 

Testing Jedis API Using Junit Test Case in Eclipse IDE

Prerequisites

  • Eclipse (any version) with Maven capabilities
  • Java 8+
  • Junit
  • Redis and Jedis

Installing Redis Server on Windows   

  1. Click on the link: https://github.com/dmajkic/redis/downloads
  2. Download redis-2.4.5-win32-win64.zip file
  3. Unzip the file and go to the 64bit folder. There you can find redis-server.exe
  4. To start the Redis server, execute the redis-server.exe file.

Installing Eclipse-IDE on Windows    

    1.Click on the link: https://www.eclipse.org/downloads/download.php?file=/oomph/epp/2020-09/R/eclipse-inst-jre-win64.exe

    2. Download eclipse-inst-jre-win64.exe file and run the eclipse installer.

Java Annotated Monthly – September 2020

September’s here, and that means back to work, back to school. Or not. It feels like the world is applying a lot of wishful thinking and behaving as if everything is going back to normal. With so much uncertainty right now, it’s a tempting approach for sure.

Anyway this is supposed to be about Java. This month we have another huge edition for you, and it includes the inevitable look at Java 15, a bunch of news about Java 16, articles and videos on testing, Java / Jakarta EE, and Java libraries.

How to Test Gradle Plugins

In this article, I share my experience of creating functional tests for a custom Gradle plugin and how to configure the plugin project to collect code coverage metrics from tests.

In the previous article, I described how to build a custom Gradle plugin. Here, we will continue to work with it. Before we start, I’d recommend recapping things in the previous article to get a better understanding of where we started.

Spring 5 Web Reactive: Flux, Mono, and JUnit Testing

The reactive-stack web framework, Spring WebFlux, has been added to Spring 5.0. It is fully non-blocking, supports reactive streams back-pressure, and runs on such servers as Netty, Undertow, and Servlet 3.1+ containers.

Reactive processing is a paradigm that enables developers to build non-blocking, asynchronous applications that can handle back-pressure (flow control). Reactive systems better utilize modern processors. Also, the inclusion of back-pressure in reactive programming ensures better resilience between decoupled components.

Testing Asynchronous Operations in Spring With Spock and Byteman

This is the second article that describes how to test asynchronous operations with the Byteman framework in an application using the Spring framework. The article discuss how to implement the Spock framework, while the first, "Testing Asynchronous Operations in Spring With JUnit and Byteman", focuses on implementing tests with JUnit4.

It's not necessary to read the previous article because all of the essentials are going to be repeated. Nevertheless, I encourage you to read that article if you are interested in testing asynchronous operations with JUnit.