ios - Unit Code testing of internal functions -


i newbie on testing , stumbling testing internal functionality on code parts. how test privateparseandcheck and/or privatefurtherprocessing functionality different input, dont want public functions?

-(bool) publicfunction() {    //some stuff network    nserror* error;    nsdata* data = load(&error);   //now got data , parse , check   bool result = privateparseandcheck(data, error, ...);    if( result ) {     privatefurtherprocessing();   }   return result; } 

is re-writing code solution? interested in experiences tips/solutions on xcode server.

if there straightforward way test want public methods, so.

if not, have choice: can expose method test code. this common practice, not recommend this. inhibits other option…

or, expose method completely. if makes feel uncomfortable, there class trying out. extract class (the methods want test , whatever else makes sense go them.) can test class.

this helpful when coming different conditions (such different errors) difficult. extract, , it's easy.

further reading: testability, information hiding, , class trying out


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -