Git Product home page Git Product logo

Comments (4)

luke-biel avatar luke-biel commented on July 22, 2024 2

Hello,
nice to see our crate put to use.
I can see where your problem comes from, and test_case unfortunately doesn't support replacing #[test] attribute yet. However, what @d-e-s-o has mentioned in the linked issue is a solution here (it's in async section, thus I can understand confusion, the feature was initially introduced to work with async tests).
I've managed to get the example working via replacing import with an explicit path:

use test_case::test_case;

#[test_case(4,  2  ; "when operands are swapped")]
#[test_case(-2, -4 ; "when both operands are negative")]
#[test_case(2,  4  ; "when both operands are positive")]
#[test_env_log::test]
fn multiplication_tests(x: i8, y: i8) {
    let actual = (x * y).abs();

    assert_eq!(8, actual)
}

This way test_case can internally expand multiplication_tests into 3 separate methods first, and after that test_env_log can add it's extras.

If this solves your problem, please close this issue

from test-case.

luke-biel avatar luke-biel commented on July 22, 2024 1

Hmm, that's definitely not a desired result, must've slipped in testing. I'm gonna create a separate bug issue for this.

from test-case.

pinage404 avatar pinage404 commented on July 22, 2024

Hello,

I had not tested in this order

Your solution solves my problem

Thank you !

from test-case.

newsch avatar newsch commented on July 22, 2024

Thanks for this useful crate!

When I use the latest test-case and test-log (new name of test-env-log) together, I get duplicate copies of each test generated.
I also tried it with what I think were the versions from when this issue was created and have the same problem.

Full example in this gist

#[cfg(test)]
mod tests {
    use test_case::test_case;

    #[test_case(0, 0 ; "the same")]
    #[test_case(0, 1 ; "different")]
    #[test_log::test]
    // #[test_env_log::test]
    fn equality(a: usize, b: usize) {
        log::info!("a: {}", a);
        log::info!("b: {}", b);
        assert_eq!(a, b)
    }
}
Output
running 4 tests
test tests::equality::the_same ... ok
test tests::equality::the_same ... ok
test tests::equality::different ... FAILED
test tests::equality::different ... FAILED

failures:

---- tests::equality::different stdout ----
thread 'tests::equality::different' panicked at 'assertion failed: `(left == right)`
  left: `0`,
 right: `1`', main.rs:18:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- tests::equality::different stdout ----
thread 'tests::equality::different' panicked at 'assertion failed: `(left == right)`
  left: `0`,
 right: `1`', main.rs:18:9


failures:
    tests::equality::different
    tests::equality::different

test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass '--bin main'

from test-case.

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.