Skip to content

Tests are NOT testing exceptions #451

@justinyoo

Description

@justinyoo

Describe the bug

While reviewing #447 , I found tests are actually NOT testing codes. Current tests look like this:

var ex = Assert.Throw<...>(... {{method to be tested}});

But it's not actually testing the method. It forcibly throws an exception. Therefore, all the tests should be changed in the following way:

// methods with no async/await
Action action = () => MethodToTest();
action.ShouldThrow<SomethingException>()
      .Message.ShouldContain("something message");

// methods with async/await
Func<Task> func = async () => await MethodToTest();
func.ShouldThrow<SomethingException>()
    .Message.ShouldContain("something message");

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions