I'm a bit confused on how to properly write unit tests for my application. Actually i want to know if i have to rewrite an existed method and modify it for junit or just call my existed method and use assert. So far, i use the second option, but i've came across with a problem. For example, inside a Controller method i'm getting the currently logged in user and pass it to some services. If i call this method through JUnit it will show null exception because there is no logged in user. So, 1) do i have to rewrite these kind of methods for testing purposes? 2) Is it proper to call existed methods and use assertion anyway? Thanks
Aucun commentaire:
Enregistrer un commentaire