list of dots

User Manual    [Previous]   [Next]   

Basic Testcase

Testcase can be embed within the Umple model and will be generated when using the Test generator. A testcase can be embedded at the class-level or the model-level.

    A testcase canonsists of the following elements:

    Initialization: ~identidier ~name = ~value;

  • ex: ~identifier ~objectname ( ~Parameters );
  • Person p ("name", 345);
  • Action: ~identifier ~name = ~value;

  • | ~name = ~value ;
  • Integer number = 12345;
  • number = student.numberOfMentors();
  • Assertions: ~assertion ( ~assertionCode )

  • assertTrue( p.setName("Jane"));
  • - assertTrue (bool)
  • - assertFalse (bool)
  • - assertEqual (value1 , value2)
  • - assertNull (value)
  • - assertAttribute (attributeName) , to be presence in generated code
  • - assertMethod (methodName) , to be presence in generated code

Example

class Student {
	id = "ID123";
	name = "John";


	test checkSetId {
	Student s ();

	assertTrue(s1.setId("ID432"));

	}
}
      

Load the above code into UmpleOnline

 

Another Example

class Student {
	id;
	name;

	test checkSetId {
	Student s ("98CS","Jane");

	assertEqual(s.getId(),"98CS");

    s.setName("Roger");
	assertFalse(s.getName() == "Jane");

	}
}
      

Load the above code into UmpleOnline