Understanding What We’re Testing: The Profile Class
Learn to test the profile class by understanding the conditions one can write tests for.
We'll cover the following...
Let’s look at a core class in iloveyouboss, the Profile class:
The Profile class
This looks like code we come across often! Let’s walk through it.
-
A
Profile(line 5) captures answers to relevant questions one might ask about a company or a job seeker. For example, a company might ask a job seeker, “Are you willing to relocate?” AProfilefor that job seeker may contain anAnswerobject with the valuetruefor that question. -
We add
Answerobjects to aProfileby using theadd()method (line 18). AQuestioncontains the text of a question plus the allowable range of answers (true or false for yes/no questions). TheAnswerobject references the correspondingQuestionand contains an appropriate value for theanswer(line 29). -
A
Criteriainstance (see line 22) is simply a container that holds a bunch ofCriterions. ACriterion(first referenced on line 27) represents what an employer seeks in an employee or vice versa. It encapsulates anAnswerobject and aWeight...