testcontainers / testcontainers/testcontainers-java
[FEATURE] Support easily running java unit tests inside a container
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Description
It would be great if there was a way to easily run Java code inside a Docker container. A use case for this is to run a unit test that relies on a particular environment that is provided by a container e.g. running a unit test of some Java code that uses Tesseract installed inside a container. The java unit test can run outside the container, but since it requires a particular version and installation setup of Tesseract running natively, it would be best if the unit test was actually run inside the container, and any assertions and such are reported back to the initiating test.
I think one way to accomplish this goal is probably via remote code execution i.e. a java program is started inside a user-specified container [1] by the test. The test then sends the executable code to the java program running inside the container [2], which executes it, and then sends the result (exception or test completion) back to the test. The test then rethrows the assertion, or passes.
[1] This container would obviously need to have java so that it can run the remoting program.
[2] How? Open question, but the user would probably have to define which dependencies they want to copy into the container (via a DSL) and perhaps implement an interface that triggers the actual in-container test, the compiled version of which is also copied into the container.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by scoping the proposed remote code execution flow between a Java unit test and a user-specified Docker container, including dependency and compiled-test transfer. Done means a maintainable way to run assertions in-container and report failures back to the initiating test; the issue names no files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java
- Domain
- devops, testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100