News for hackers. Stuff that matters.
Re:Why I don't mock by camus2 on Wednesday May 28, 2014 @10:12AM (#7809977)
So, a lot of ideas are thrown here without any real use cases.People say "mocks are bad,whitebox testing is bad".But how can I unit test anything without mocks?

let's take javascript.I cant generate mocks from my code,i have to write them.I have this data access object that takes a connnection.

    var dao=new Dao(connection);
    dao.getById(1,function(err,res){ console.log(res) });
Tell me how do I unit test getById in isolation without mocking connection,without doing whitebox testing,without knowing what actually happens in my getById.

the obvious thing here is to spy on a hypothetic connection.query, fake a db call and return a predictable result.I cant do anything without a mock.

There are no comments on this comment yet.