Wednesday 17 July 2019

Get Raspberry Pi board details from Raspbian

I have a Raspberry Pi that I didn't use regularly. I brushed off the dust and wanted to play around with the hardware again but I wasn't sure of the pin configuration. I then came across this handy utility that displays a summary of the Raspberry Pi hardware.
 The pinout command gives this summary.


This is what the output looks like. From this you can see that the Raspberry Pi Model is 3B V1.2

Saturday 15 June 2019

org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [java.lang.String arg0] in method [void ParametrizedTest.test(java.lang.String)].

I was experimenting with JUnit 5 and Parameterized Tests and hit the following error.

org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [java.lang.String arg0] in method [void ParametrizedTest.test(java.lang.String)].

This was the code that was used to trigger the error.


import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertTrue;

public class ParametrizedTest {

    @Test
    @ParameterizedTest
    @MethodSource("stringProvider")
    void test(String string) {
        assertTrue(true);
    }

    public static Stream stringProvider() {
        return Stream.of("", null, "123");
    }
}

The issue is that the test method is annotated with both @Test and @ParameterizedTest. When using parameterized tests, you should only annotate your test method with @ParameterizedTest and not @Test. Removing the @Test annotation will prevent this error.


import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertTrue;

public class ParametrizedTest {

    @ParameterizedTest
    @MethodSource("stringProvider")
    void test(String string) {
        assertTrue(true);
    }

    public static Stream stringProvider() {
        return Stream.of("", null, "123");
    }
}