Skip to content

Concerns about multiple logical assertions #26

Closed
@AlexArchive

Description

@AlexArchive

The consensus among the community appears to be that each test should have but one logical assertion.

If a developer wants to test that a controller returns a model of the correct type explicitly, they must also test that a view with a particular name is rendered - that's two logical assertions.

[Test]
public void Index_ReturnsCorrectModelType()
{
    repository
        .Setup(repo => repo.All())
        .Returns(PostsMother.CreateEmptyPosts());

    controller
        .WithCallTo(c => c.Index(1))
        .ShouldRenderDefaultView()
        .WithModel<PagedList<Post>>();
}

I suspect that this kind of test goes against your philosophy but I am going to bring it up for discussion anyway.

Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions