The Pitfalls in C++ Unit Testing

Recently there has been a surge of interest in C++ unit testing. C++ unit testing has not been common in C++ development in the past.

Although C++ is a kind of programming language that fits well with unit testing, several complexities require extra care. In this article, I’ll discuss the most common pitfalls.

The Complete Unit Testing Collection [Tutorials and Frameworks]

Breaking Unit Testing Down

Unit Test Lifecycle

The Anatomy of Good Unit Testing

I think of unit tests as an extension to my code. A thorough testing process offers peace of mind that when refactoring the code or making performance improvements, the units still function as expected. It can also find bugs and edge cases and avoid regressions during refactoring.

I come from a.NET / C# background and have compiled this collection of thoughts and tidbits that I find useful when writing tests.

I Tried Test-Driven Development for A Month and Survived

When I first heard about Test Driven Development (TDD) I immediately wrote it off as a technique that will slow me down, how on earth should I know exactly what my code will look like if I often refactor while coding. Besides, I’ve been coding for many years and understand how to write code that is “easily” testable. For me it made perfect sense to ignore this crazy idea. Then I realised TDD doesn’t mean what I thought it meant, you see the first time TDD was explained to me many years ago I was told “You write all your unit tests first” and that is what stuck with me. Even now when I ask developers what they understand about TDD that is the response I receive.

So what is TDD?

Test Driven Development is an iterative programming workflow whereby you write a single unit test and then write the code, if required, to make the test pass. When the test passes you refactor your code, including the tests, before writing the next test.

How to Unit Test Classes Which Create New Objects

Learn how to conduct effective unit tests.

First of all, I will start with a disclaimer that I am a strong proponent of using the simple factory programming idiom and by extension of using the Factory Method Pattern, instead of creating objects inside classes. The factory idiom helps you to insulate your code to changes thereby adhering to the Open to Extension Close to modification principle of object-oriented programming.

You may also like: Unit Testing: The Good, Bad, and Ugly

Also, the idea is to write testable code, not to write a hack to test code.

Strengthening Testing through Mutation: A DevOps Engineer’s Experience

I work as a DevOps engineer for a large public-facing application, which has around 90+ microservices (Java-based). Consistently, we are hit by scenarios that we’d discover in the field, which were not caught in any of our testing. Despite improving our test strategies and code coverage assessments, we were unable to assess the "strength" of our test cases.

We looked around for options and solutions that could help us to be more sure about our test cases and the code we develop. As a DevOps engineer, my responsibility was to identify options and trial them to fix this problem and include it as part of our automated build process.

Compare Software Testing Methodologies for Your Needs

The choice is yours!

The choice is yours. You know your product. You know the problem it solves and why it will soon become vital to the working lives of untold numbers of users. What you might not know is how best to test that product so that your development intention becomes a product reality.

There are a number of different software testing methodologies available to you to reach that reality. Each is designed with a specific purpose in mind, and each has value in a comprehensive test plan.

Automated Software Framework For Python With the unittest Module

unittest and Python.

Software testing plays a vital role in ensuring that the original output of a software product matches the desired output by offering certain test inputs to the software. Software testing is regarded as a vital step as it plays a vital role in finding the flaws and errors in the product within a short interval of time.

Software testing, or QA testing, is generally divided in two major categories, automated testing and manual testing. Automation testing refers to the execution of different tests with the aid of a script, in place of a human. This write-up discusses a few of the tips of automated software testing through Python.

Best Java Unit Testing Frameworks

Learn more about the best Java unit testing frameworks.

Unit testing is an important skill for programmers. With that said, what are the best frameworks you can use to write great unit tests in Java?

You may also like: 8 Benefits of Unit Testing

What We Will Learn

  • What are the best Java unit testing frameworks?
  • What is JUnit? How do you use JUnit for unit testing?
  • What is Mockito?
  • What is mocking?
  • How do you write unit tests with Junit, Mockito, AssertJ, and other frameworks?
  • What is the best Java unit testing framework for writing great asserts?

The Base Unit Testing Framework — JUnit/TestNG

Whenever you write a unit test, you execute the code and then check its output. You need a basic framework in place to run a large number of tests in a similar manner.

8 Benefits of Unit Testing

Originally published Jan. 18, 2017

If there were ever a time to compartmentalize...

As we write a lot about AgileCI, and TDD, we had to mention unit testing. This time, we will talk about what unit testing is, why it is part of Agile methodology, and the main benefits of using it.

Unit Testing in ReactJS using Jest and Enzyme

According to Michael Feathers, “Any code that has no tests is a legacy code.” So as a developer it is your duty to avoid creating legacy code by using test-driven development (TDD).

There are many tools available for unit testing in ReactJS but we will be going through Enzyme and Jest.

Integration Testing: What It Is and How to Do It Right

For software to work properly, all units should integrate together and behave correctly.

Integration testing is like inviting your two favorite groups of friends to the same birthday party and hoping they all get along. Will they cooperate and “blend” when they’re all in the same room? The only way to know is to perform an “integration test” by pulling them all together and seeing how they interact with one another.

SQL Clone for Unit Testing Databases

Sometimes, when you are performing unit or integration tests whilst developing code, you need to be able to do something extreme, such as mangling a test database or two, repeatedly, each time subsequently restoring it to its original state before running the next test. Often, especially in integration tests when you are testing processes, you will need run a ‘setup’ process to establish a known database data state, then run the process, test that the final data state matches that which your business rules dictate it should be, and finally run a ‘teardown’ process to restore things to how they were at the start.

The difference with a unit test is that the developer is constantly running the test and resents it if the set up or teardown processes take any delay longer than what in my misspent youth we’d call ‘the time it takes to roll a cigarette.' Integration tests are generally done in a more dignified manner after the build, so there is less pressure on time. In this case, it is a unit test that we need, though it can be adapted as an integration test if the component under test gets to be part of a process.

Unit Testing of jBPM Process Flows

Unit testing is an important step in the software development life cycle to ensure that your product works the way it is intended to work. Back in the day, it used to be just a step that developers had to perform to evaluate their work. In today’s world, it has become an essential part of the CI/CD pipeline as it is not just used to determine quality based on functionality but also to determine code promotion eligibility based on various numbers (pass/fail ratio or code coverage percentage).

jBPM, being one of the most modern, open-source bpm products, provides rich capabilities for unit testing BPM processes. This allows jBPM processes to be treated just like any other Java-based artifact. The jBPM tool kit provides an extension of JUnit test classes that allow one to easily unit test business processes defined in BPMN2.