You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
It's not always convenient that #[sqlx::test] invokes the underlying async runtime. And it's a blocker for me having the test function marked with #[test]. It's because when I use harness = false for my custom test suite setup, #[test] functions are skipped by rustc and not included in the test binary.
Describe the solution you'd like
I'd like to:
Have the concerns of "test DB setup + run migrations" and "async runtime start" separated and opt-in for #[sqlx::test]
Have the option to avoid marking the test function with #[test] (when I only need the "test DB setup + run migrations" concern)
Maybe even have a public API that will allow calling this "test DB setup + run migrations" code explicitly, exposing the function generated by #[sqlx::test]
Additional context
In general, I'm trying to use #[sqlx::test] with a BDD library https://github.com/rust-rspec/rspec. And the current API of #[sqlx::test] doesn't allow me to build a custom test suite with harness = false. My idea was to have a sync top-level function marked with #[tokio::test] to be the "async main", then each test closure will manually invoke the test function generated by #[sqlx::test]
The text was updated successfully, but these errors were encountered:
Yeah, I would like that too.
Though in my case it is mostly because I would like to use #[sqlx::test] in doc tests.
(Or having the option to call it manually as you would with tokio::runtime::Builder instead of #[tokio::main])
What the #[test] attribute prevents, as functions marked as #[test] are only compiled in with the test profile, not the doctest profile
Though having looked at sqlx-core::testing, I assume that would require a fair bit of refatoring, because currently every TestFn::run_test() call starts its own runtime.
Is your feature request related to a problem? Please describe.
It's not always convenient that
#[sqlx::test]
invokes the underlying async runtime. And it's a blocker for me having the test function marked with#[test]
. It's because when I useharness = false
for my custom test suite setup,#[test]
functions are skipped byrustc
and not included in the test binary.Describe the solution you'd like
I'd like to:
#[sqlx::test]
#[test]
(when I only need the "test DB setup + run migrations" concern)#[sqlx::test]
Describe alternatives you've considered
https://github.com/tyrchen/sqlx-db-tester
Additional context
In general, I'm trying to use
#[sqlx::test]
with a BDD library https://github.com/rust-rspec/rspec. And the current API of#[sqlx::test]
doesn't allow me to build a custom test suite withharness = false
. My idea was to have a sync top-level function marked with#[tokio::test]
to be the "async main", then each test closure will manually invoke the test function generated by#[sqlx::test]
The text was updated successfully, but these errors were encountered: