java - Junit The null test -


the teacher gave example test our code, gave me error, if can figure out why gives me error, i'll appreciate...

public int compareto(player other) {     // todo auto-generated method stub     if (points < other.points) return -1;     if (points > ohter.points) return 1;     return 0; }  public void setpoints(int points) {     this.points = points; } 

the result of test:

java.lang.exception: unexpected exception, expected <java.lang.illegalargumentexception> <java.lang.error>.

the test:

@test(expected=illegalargumentexception.class) public void thenulltest(){     player2 = null;      player1.setpoints(4);     player1.compareto(joueur2); } 

if have joueur2 instead of player2 in snippet, seeing "unresolved compilation error" (which java.lang.error) instead of expected illegalargumentexception (which not java.lang.error), code not compile as-is.

if that's case, please make sure code compiles before testing (in case, fix "joueur2"), , not disregard compiler errors during build.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -