dimanche 1 juillet 2018

Is it possible to run code after all tests have finished?

I would like to run a teardown function (i.e. write a log to a file) when all of my tests have finished. In this example, the function would run after both it_works_foo and it_works_bar are complete:

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

#[test]
fn it_works_bar() {
    assert_eq!(2, 2);
}

I'm looking for something like Mocha's after behavior:

describe('hooks', function() {
  after(function() {
    // runs after all tests in this block
  });

  it('it_works_foo', () => {});

  it('it_works_bar', () => {});
});

Is this possible?

Aucun commentaire:

Enregistrer un commentaire