-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Streamline unit test execution in CI vs. locally
The current way of running JUnit tests has some drawbacks. The CI executes tests by running multiple `mvn` commands. When running tests locally, it is tedious to run the same multiple commands, in order, for example, to get the same coverage as the CI gets. Ideally the tests are configured in the project itself, in the pom.xml file and by annotations on the tests, so that simply running `mvn test` will do everything needed. In order to achieve this, adapt the tests to be parameterized, so that JUnit takes care of running them with different RESP protocols. It is OK to use environment variables in general, for example for injecting connection details. But it is not OK to use environment variables for driving test execution, by injecting a RESP version and running the tests multiple times. If I have to run more than `mvn test`, it does not feel right. Some tests rely on static fields and @BeforeClass and @afterclass annotations. These do not work well with parameterized tests, so remove the static and switch to @before and @after annotations. The Makefile is a bit unpolished, i.e. the sequence of tasks is controlled manually when it could be controlled declaratively, and the `start` and `stop` tasks do not cover starting and stopping the Redis Stack docker. Take care of these aspects. All in all, now if I run `make test` I know I get the correct coverage in the JaCoCo report. And the CI can also just run `make test`, without additional work.
- Loading branch information
Showing
95 changed files
with
851 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/test/java/redis/clients/jedis/commands/CommandsTestsParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package redis.clients.jedis.commands; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import redis.clients.jedis.RedisProtocol; | ||
|
||
public class CommandsTestsParameters { | ||
|
||
/** | ||
* RESP protocol versions we want our commands related tests to run against. | ||
* {@code null} means to use the default protocol chosen by the Redis server. | ||
*/ | ||
public static Collection<Object[]> respVersions() { | ||
return Arrays.asList( | ||
new Object[]{ null }, | ||
new Object[]{ RedisProtocol.RESP2 }, | ||
new Object[]{ RedisProtocol.RESP3 } | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.