Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You don't need to test that. ... The code is obvious. There are no conditionals, no loops, no transformations, nothing. The code is just a little bit of plain old glue code.

Here's the code:

  @Override
  public void initialize(WatchlistDao watchlistDao) {
    watchlistDao.loadAll(watchListRow -> watchlists.add(watchListRow));
  }
Maybe I'm dense, but this code raises at least one question that I would prefer to see answered by tests.

The parameter watchlists appears to be defined in a scope above the one under test. What happens if watchlists is null for some reason? What should be the behavior?

Then there's the tricky question of what to do as this method evolves. Next month, a watchListRow might need to be updated with a value before being added to watchlists. Later, a check might be added to ensure some property exists on watchListRow. At what point will a test be written for this method?



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: