how to use intance variable for junit with getter and setters java

Viewed 33

what I'm trying to do with my getters and setter is create a string inside a method called teststring output. I go through assertequals with string form ("s%", testname) and use the getter with as null in assertrue but it give me the error your name is now testname the string value. when it expects that but intellij says the actual output is nothing.

  void setName() {
    assertTrue(player.getName() == null || player.getName().isBlank(), "The player's name should start as a blank or null string.");
    String testName = "jason";
    player.setName(testName);
    assertEquals(testName, player.getName());
    assertEquals(String.format("Your name is now %s", testName), outContent.toString().trim());
}

 public void setName(String newName) {
name = newName;
}




public String getName() {
    return name;
}
0 Answers
Related