Skip to content

TestParameter value is not url encoded #56

@ArvindJoshi-okta

Description

@ArvindJoshi-okta

Hello,
I have a test parameter that is an user agent and when I provide the string as is, JUnit doesn't pick the tests up. The test parameter is sent in a class member. For example,

@RunWith(TestParameterInjector.class)
public class MyTestClass {
    private static final String WINDOWS_USER_AGENT_STRING = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36";

    @TestParameter({WINDOWS_USER_AGENT_STRING})
    private String stringParameter;

    @Test
    public void test() throws IOException {
    }
}

I am running the test with this command (note, my use case is to run a specific test case)
mvn verify -Dit.test="MyTestClass#test*"

Output I see is this:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

The test gets picked up if I provide an encoded string like this:

private static final String WINDOWS_USER_AGENT_STRING = "Mozilla%2F5.0+%28Windows+NT+10.0%3B+Win64%3B+x64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F101.0.4951.54+Safari%2F537.36";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions