mardi 30 août 2016

Unit test for class/method who use real folder and files

(I'm really new to ruby so forgive me if my question sound stupid)

I currently write a rails app and inside it I made a lib. This lib is supposed to scan a folder and retrieve each media (image and videos) and their exif data (using mini_exiftool).

In the meantime, I heard of TDD and how unit-test are a really big deal, So I wanted to try it myself (still far from that).

So…I come to my question (finally): Writing test for simple output seem really easy but since my class is supposed to return a (big) array of hashes of every media with inside: basename ,path and another hash with exif data (list really long).

1/Should I use a "test" folder with some files (some media and some others) ? If yes, where should I put it (the folder) (don't forget this is a lib) ? and I probably need more that one folder test ? Considering that media can be very big it will considerably put some weight to the app)

2/if not, what should I do ?

3/How I can be sure that my written test is correct itself ? (writing true or false in assert is easy but a big return written manually is a source of multiple errors)?

Aucun commentaire:

Enregistrer un commentaire