testcontainers/testcontainers-rs
Fork: 142 Star: 775 (更新于 2024-12-14 21:24:38)
license: Apache-2.0
Language: Rust .
A library for integration-testing against docker containers from within Rust.
最后发布版本: 0.22.0 ( 2024-08-31 03:22:23)
Testcontainers-rs
Testcontainers-rs is the official Rust language fork of http://testcontainers.org.
Usage
testcontainers
is the core crate
The crate provides an API for working with containers in a test environment.
- Depend on
testcontainers
- Implement
testcontainers::core::Image
for necessary docker-images - Run it with any available runner
testcontainers::runners::*
(useblocking
feature for synchronous API)
Example:
- Blocking API (under
blocking
feature)
use testcontainers::{core::{IntoContainerPort, WaitFor}, runners::SyncRunner, GenericImage, ImageExt};
#[test]
fn test_redis() {
let container = GenericImage::new("redis", "7.2.4")
.with_exposed_port(6379.tcp())
.with_wait_for(WaitFor::message_on_stdout("Ready to accept connections"))
.with_network("bridge")
.with_env_var("DEBUG", "1")
.start()
.expect("Failed to start Redis");
}
- Async API
use testcontainers::{core::{IntoContainerPort, WaitFor}, runners::AsyncRunner, GenericImage, ImageExt};
#[tokio::test]
async fn test_redis() {
let container = GenericImage::new("redis", "7.2.4")
.with_exposed_port(6379.tcp())
.with_wait_for(WaitFor::message_on_stdout("Ready to accept connections"))
.with_network("bridge")
.with_env_var("DEBUG", "1")
.start()
.await
.expect("Failed to start Redis");
}
Ready-to-use images
The easiest way to use testcontainers
is to depend on ready-to-use images (aka modules).
Modules are available as a community-maintained crate: testcontainers-modules
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
最近版本更新:(数据更新于 2024-09-03 02:59:42)
2024-08-31 03:22:23 0.22.0
2024-08-06 07:42:01 0.21.1
2024-07-31 04:09:40 0.21.0
2024-07-18 21:25:14 0.20.1
2024-07-07 23:51:03 0.20.0
2024-06-28 17:19:49 0.19.0
2024-06-16 05:02:45 0.18.0
2024-05-27 04:47:42 0.17.0
2024-05-02 05:56:20 0.16.7
2024-05-01 05:28:48 0.16.6
主题(topics):
docker, integration-testing, rust, test-automation, testcontainers, testcontainers-rust, testing
testcontainers/testcontainers-rs同语言 Rust最近更新仓库
2024-12-22 08:48:41 lapce/lapce
2024-12-21 23:25:36 tw93/Pake
2024-12-19 19:31:32 dashpay/platform
2024-12-18 10:31:25 DioxusLabs/dioxus
2024-12-17 17:18:34 lanyeeee/jmcomic-downloader
2024-12-16 23:19:51 meilisearch/meilisearch