GithubHelp home page GithubHelp logo

Incompatibility with rstest's once about nextest HOT 3 CLOSED

jacg avatar jacg commented on August 27, 2024
Incompatibility with rstest's once

from nextest.

Comments (3)

la10736 avatar la10736 commented on August 27, 2024

I guess that use one process per test makes useless #[once] attribute. I think that there are scenario where instantiate some resource shared across tests (like docker instances or populate db) only once is really useful... in this case the model one process one test don't works very well.

Is a chance introduce an option to run tests in the same executable with multiple thread that can share resources? I know why you adopt this model and all benefits that this model have, but this kinds of scenario are really common in integration tests.

from nextest.

sunshowers avatar sunshowers commented on August 27, 2024

Thanks for the report and the debugging! Yes, one process per test is incompatible with that kind of initialization. The options are:

  • Initialize separate, isolated universes for each test, which can work with files on disk and some database situations, but is definitely harder to do with Docker by my understanding.
  • Combine all the individual tests into a single #[test] so that it's all run together.

#27 tracks adding the option to add a mode where all tests are run within the same process. It is quite nontrivial, however -- one of the challenges is that individual test data isn't exposed by stable Rust. Regardless, I would be happy to welcome a pull request that does something reasonable in that case.

I think I'm going to close this as a duplicate of #27, since solving that should address this.

from nextest.

jacg avatar jacg commented on August 27, 2024

Separate, isolated universes for each test, would indeed be useful for avoiding collisions (and in the case of files colliding, this can and should be addressed with some unique filename-generation utility), but #[once]-like features are mostly useful for sharing resources between tests, either because setting up the resource is expensive, or because the tests are somehow coupled by the resource.

Combining tests into an individual test would be a possibility in the latter cases, but then you lose the benefits of fine granularity of failure reporting that comes with small, separate tests. Especially annoying would be the loss of parametrized tests (such as rstest's cases, where different data are injected into the same test).

But these are second-order details. I appreciate that it's difficult, and that solving #27 should address this, so I agree with closing.

Thanks again for the excellent crate!

from nextest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.