Junit - testing a private class method that never sets

So, our stack is on Spring, and they say that the class is Wizardcalled only from a change in the user interface. On xhtmlit is called like this:

`<.....onchange="changeValue()" value="wizard.type.name">`

A class is never created anywhere in the code, and the only constructor in the class is:

public Wizard(){}

And tell me, it getName()calls a private method getWizardWeapon()- how do I get tested getWizardWeapon()in junit in a separate project (say TestWizard, but in the same workspace)?

+4
source share
2 answers

You do not need to check personal methods. Tests should pass only through open interface methods. So your tests should go through getName().

, , - , . , , , - ( ).

API , getName() getWizardWeapon(). ( ).

, , , , ?

+4

@dkatzel: , , getWizardWeapon() not private, package private (, , , main/com/example/Wizard test/com/example/TestWizard).

+2

All Articles