Testing
Test Driven Development (TDD)
Preferably, Test Driven Development (TDD) should be adopted in the development process. This leads to improved code quality and design from the very beginning.
Using the TDD approach when addressing a bug should ideally be used. First, one or more tests should be created to replicate the bug. These tests should initially fail. Second, the bug can then be fixed where the passing tests will confirm the bug is resolved. Moreover, these tests will prevent any regression from taking place.
Unit/Integration Testing
Not practicing TDD? Not everyone does so when writing tests after the fact, we believe that writing unit tests should take as long as writing the unit being tested. Tests should verify boundaries and cover failure scenarios.
Although it's not the ultimate metric, measuring code coverage is important and ideally, it should be included in the build pipeline. If the coverage falls below the required threshold, the build should fail.
A test should be clear in its intention. We prefer the given/when/then pattern. This makes it clear what the test is doing and what is expected.
e.g.
@Testvoid shouldReduceProductInventoryWhenOrderPlaced() { // Given Product product = new Product.Builder() .name("Acme Widget") : .build(); getMockInventory() .forProduct(product) .setQuantity(5); // When Order order = orderService.placeOrder(product, ...); // Then int actualQuantity = getMockInventory() .forProduct(product) .getQuantity(); assertThat(order.getStatus(), equalTo(OrderStatus.PLACED)); assertThat(order.getProduct(), equalTo(product)); assertThat(actualQuantity, equalTo(4));}
Performance Testing
Performance testing is crucial for any system or application. It's essential to comprehend how the system behaves as a whole under extreme load.
Yobibyte Solutions has expertise in utilising tools like JMeter and Postman to emulate requests.