Skip to content

How to do integration testing in axum ? #1423

Answered by davidpdrsn
roynrishingha asked this question in Q&A
Discussion options

You must be logged in to vote

Using "integration tests" (i.e. tests stored in the tests directory rather than src) is tricky because it requires you expose things (via pub) from your crate. In most cases if you're building a binary that isn't necessary. This is mainly intended for libaries.

I recommend you write tests in directly in src like its done in this example https://github.com/tokio-rs/axum/blob/main/examples/testing/src/main.rs

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@roynrishingha
Comment options

@davidpdrsn
Comment options

Answer selected by davidpdrsn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants