Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java test fails (tostring)

Tags:

java

I have this Java program, but my test gives me this message:

testEmployeeTostring: failed testEmployeeTostring expected <[id[= 1013, name= Jubal Early, job = ]procurement]> but was: <[id[= 1013, name= Jubal Early, job = ] procurement]>

I had to use @Override and I think that's the problem. I hope someone can figure out the problem with this:

public class Employee {

        int id;
        String name;
        JobType job;

        public Employee(int id, String name, JobType job)
        {
                this.id = id;
                this.name = name;
                this.job = job;
        }

        @Override public String toString()
        {
                return ("["+ "id =" + id + ", name = "  + name + ", job = " + job + "]");
        }
}
like image 599
Adeq Hero Avatar asked Nov 30 '25 02:11

Adeq Hero


1 Answers

There is a space between ] and 'procurement'

job = ] procurement

like image 185
JavaKB Avatar answered Dec 02 '25 14:12

JavaKB