TDD - How Much Will You Check?

I am working on a new project, and I am using the repository template, I have my repository that retrieves data from the database and the “service” class, which uses the repository and runs all the business logic.

something similar to the following:

public class UserRepository : IUserRepository
{
    public IQueryable<User> GetUsers()
    {
    // do stuff
    }
}

public class UserService 
{
    public IList<User> GetUserById
    {
        var rep = new UserRepository();
        var users = rep.GetUsers();
        // do business logic
        return users.ToList();
    }
}

Do you check both UserService and UserRepository, or do you think testing will be enough for maintenance? I believe that since the service uses the repository, this should be fun, but it kills the code coverage.

+3
source share
8 answers

, , - UserRepository, UserService, UserRepository , UserService.

+9

:

, , , , ; -)

TDD, . TDD; ( )

[ downvoting!; -)]

+9

, True Path :-) , , UserService , .

: , UserService, . , , UserService, . , .

+4

. , , .

+1

:

  • . , , , , .. , / , .

  • TDD - , , , , , , , , . .

, UserService DummyRepository, IUserRepository. / . .

, UserRepository. . Mock, API- / , unit test .

/. , , UserService UserRepository, .

+1

TDD - , UserRepository UserService, .

eXtreme Programming, : " , ", , .

+1

, UserService - , , UserRepository (, ). , .

, , , , , .

+1

, , - , Exception, .. , EasyMock, , , Mockito, . , DB .

, . / DB , .

, Service, .

+1

All Articles