Re:Write tests. Not too many. Mostly integration
by vertex-four on Friday October 27, 2017 @09:42AM
(#15568142)
So how exactly do you test that your SQL query does the right thing? That you're using the Twitter API correctly?
[ Parent
| on HN ]
Re:Write tests. Not too many. Mostly integration
by hacker_9 on Friday October 27, 2017 @10:02AM
(#15568319)
Testing a database, or an external web service, is an integration test. They can be as simple as:
void TestCreateUser() {
var repo = new UsersRepository();
var mockUser = new User("John", "Smith");
repo.AddUser(mockUser); // db call
var addedUser = repo.GetUsers().Single(); // db call
Assert.StructureIsEqual(mockUser, addedUser);
}
For the Twitter web service, you might test that you successfully get a response, as you don't have control of what exactly comes back.