Giter Site home page Giter Site logo

Named tests about rstest HOT 7 CLOSED

infiniteregrets avatar infiniteregrets commented on July 30, 2024 3
Named tests

from rstest.

Comments (7)

la10736 avatar la10736 commented on July 30, 2024 1

@TomPridham Same example in rstest:

#[rstest]
#[case::when_both_operands_are_negative(-2, -4]
#[case::when_both_operands_are_positive(2,  4)]
#[case::when_operands_are_swapped(4,  2)]
fn multiplication_tests(x: i8, y: i8) {
    let actual = (x * y).abs();
    assert_eq!(8, actual)
}

Output should be something like

test multiplication_tests::case_1_when_both_operands_are_negative ... ok
test multiplication_tests::case_2_when_both_operands_are_positive ... ok
test multiplication_tests::case_3_when_operands_are_swapped ... ok

You can find the motivation of why I choose to leave the case_<nr> also when description is present in #167

from rstest.

la10736 avatar la10736 commented on July 30, 2024 1

Released

from rstest.

la10736 avatar la10736 commented on July 30, 2024

Ok,
the issue here is that the values are just expressions at compile time: We cannot know what value we can have at runtime.

What we can do is simply add a sanitized string from the expression by just take valid characters and discard the others. Maybe some chars can be replaced by _ (i.e. :) instead just discarding.

from rstest.

infiniteregrets avatar infiniteregrets commented on July 30, 2024

Ok, the issue here is that the values are just expressions at compile time: We cannot know what value we can have at runtime.

What we can do is simply add a sanitized string from the expression by just take valid characters and discard the others. Maybe some chars can be replaced by _ (i.e. :) instead just discarding.

Thanks for checking this! and this sounds good

from rstest.

la10736 avatar la10736 commented on July 30, 2024

I'll limit the rendered part to 64 chars.... It should be enough.

from rstest.

TomPridham avatar TomPridham commented on July 30, 2024

it would also be nice to be able to specify a string name for parameterized tests as well, similar to: https://docs.rs/test-case/latest/test_case/#example-usage

from rstest.

la10736 avatar la10736 commented on July 30, 2024

You can already do it for cases... not for values.

https://docs.rs/rstest/latest/rstest/attr.rstest.html#optional-case-description

For values doesn't have too much sense IMHO

from rstest.

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.