Coder Social home page Coder Social logo

testaun's Introduction

Testaun

Very minimalist procedural macro to help with tests, when you have to run some piece of code right before and after the actual test. You know, some sort of setup and teardown kind of thing.

I wrote it with educational purpose as I'm exploring Rust's procedural macros feature. But to be honest it kinda works and I even got to use it on Moy Sekret. Let's see.

How To

As usual, add the dependency to Cargo.toml:

    [dependencies]
    testaun = "0.1.0"

Once you have done that, it is pretty straightforward and there is a standalone test that shows it plain and simple.

    // Import the damn crate
    //

    extern crate testaun;
    use testaun::testaun_case;

    // Those functions are mandatory to be able to use #[testaun]. You'll see an
    // error if they're not provided in the current scope.
    //

    fn testaun_before() {
        println!("[BEFORE]");
    }

    fn testaun_after() {
        println!("[AFTER]");
    }

    // Try it out just like below in order to see [BEFORE] and [AFTER] printed out:
    // $ cargo test -- --nocapture
    //

    #[test]
    #[testaun_case]
    fn should_work_fine() {
        assert!(1 == 1, "oh damn! it should be the other way around");
    }

    #[test]
    fn should_work_as_normal() {
        assert_eq!(1, 1);
    }

So you can use #[testaun] or not. If you go ahead use it, you must provide two functions testaun_before and testaun_after. And that's it.

What a testaun Joe?

Yeah. Big one, dude.

Copyright

Leandro Silva <[email protected]>

testaun's People

Contributors

leandrosilva avatar

Stargazers

Nelson Júnior avatar

Watchers

 avatar James Cloos avatar

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.