java - JUnit Testing a class -


this first time i've had write j unit test , i'm stuck on how start. class represents single cell on othello board has grid , token value.

i wanted test constructor both "black" , "white" , different locations, , wanted test of setters , getters.

any appreciated.

public class boardcell {     /**      * item @ boardcell.      */     private item token;      /**      * celllocation of boardcell.      */     private boardlocation location;      /**      * constructor.      * @param row row number.      * @param col column number.      * @param token item value.      */     public boardcell(int row, int col, item token)     {         this.token = token;         location = new boardlocation(row, col);     }      /**      * sets item value.      * @param token item value.      */     public void setitem(item token)     {         this.token = token;     }      /**      * set value of item in boardcell.      * @param val value of item.      */     public void setvalue(string val)     {         this.token.setvalue(val);     }      /**      * gets item value.      * @return item @ boardcell.      */     public item getitem()     {         return token;     }      /**      * boardlocation boardcell.      * @return boardlocation boardcell.      */     public boardlocation getlocation()     {         return location;     } } 

you need start creating new class hold different tests, can call it, say, boardcelltest or boardcelltestcase.

in class, you'll need add different test cases, public void methods annotated @test.

each method should assert (with methods in assert class) need test, creating right boardcell objects , getting values, or setting new ones.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -