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

A hundred times yes. Actual tests that test an actual purpose are great. But I've seen tests that are something along the lines of

    var thing = new Thing();
    thing.shouldBe.instanceOf(Thing);
There are some things you don't need to test.


There are cases where I do tests like that. There are two reasons for them.

1. It can save time debugging failures because I know whether the basic instantiation of thing was sane or not.

2. There are cases where there are complex object instantiation tests where an object is returned according to some other logic. Obviously these need to be tested.

In the first case those aren't tests for the sake of testing the API. They are sanity checks for saving time troubleshooting other test case failures.


on the other hand

my $thing = $thingloader->new($some_complex_data); ok ($thing->isa('Specific::Kind::Of::Thing')

is fine and useful.


Doubtful. That should be using dependency injection.

At the very most you should be expecting an interface, and not having the correct one should yield a runtime error within the code to begin with.


It would be a useful test for a dependency injection framework ;-)


That's what it is. You have a unified interface for generating things, and you need to have deterministic test to make sure your thing is being generated correctly and the data generates the thing fully and correctly.




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

Search: