google / google/TestParameterInjector

TestParameter value is not url encoded

Open
#56 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
428
Forks
38
PR merge metrics
No merged PRs in 30d

Description

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";
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.