3 ms·
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?
by camus2 12y ago
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.