Recommended approach for route-based tests within routes of react-router

If you think about the responsibility of the AccessDenied component, it isn’t really to send the user home. That’s the overall behaviour you want, but the component’s role in that is simply to send the user to “/”. At the component unit level, therefore, the test could look something like this: import React, { FC … Read more

Should one test internal implementation, or only test public behaviour?

The answer is very simple: you are describing functional testing, which is an important part of software QA. Testing internal implementation is unit-testing, which is another part of software QA with a different goal. That’s why you are feeling that people disagree with your approach. Functional testing is important to validate that the system or … Read more

Embedded MongoDB when running integration tests

I have found Embedded MongoDB library which looks quite promising and does what you have asked for. Currently supports MongoDB versions: 1.6.5 to 3.1.6, provided the binaries are still available from the configured mirror. Here is short example of use, which I have just tried and it works perfectly: public class EmbeddedMongoTest { private static … Read more

Before and After Suite execution hook in jUnit 4.x

Yes, it is possible to reliably run set up and tear down methods before and after any tests in a test suite. Let me demonstrate in code: package com.test; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses({Test1.class, Test2.class}) public class TestSuite { @BeforeClass public static void setUp() { System.out.println(“setting up”); } … Read more

What Makes a Good Unit Test? [closed]

Let me begin by plugging sources – Pragmatic Unit Testing in Java with JUnit (There’s a version with C#-Nunit too.. but I have this one.. its agnostic for the most part. Recommended.) Good Tests should be A TRIP (The acronymn isn’t sticky enough – I have a printout of the cheatsheet in the book that … Read more