Created
April 16, 2019 00:01
-
-
Save luisenriquecorona/25cf493fd614bb7540d4431995b0f2f9 to your computer and use it in GitHub Desktop.
A simple class used to demostrate unit testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** A simple class used to demonstrate unit testing. */ | |
public class Person { | |
protected String fullName; | |
protected String firstName, lastName; | |
/** Construct a Person using his/her first+last names. */ | |
public Person(String firstName, String lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
} | |
/** Get the person's full name */ | |
public String getFullName( ) { | |
if (fullName != null) | |
return fullName; | |
return firstName + " " + lastName; | |
} | |
/** Simple test program. */ | |
public static void main(String[] argv) { | |
Person p = new Person("Ian", "Darwin"); | |
String f = p.getFullName( ); | |
if (!f.equals("Ian Darwin")) | |
throw new IllegalStateException("Name concatenation broken"); | |
System.out.println("Fullname " + f + " looks good"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment