samedi 23 janvier 2021

How to write test case for unit test of a class

Im working on a school project, my task is to create test cases for testing application which is a simple website created in spring framework. I know what classes will be used in this simple project, so what i want to do is to create test cases for unit testing of these classes.

e.g. class

public class PersonName {
    String firstName;
    String lastName;

    public PersonName(String firstName, String lastName) {
        this.firstName = firstName;
        this.lastName = lastName;
    }
}

So what I imagine i have to do here is create something like this:


Test case 1

  1. Description: Try to create PersonName instance with various values for firstName and lastName

  2. Test data: PersonName class

  3. Steps:

  • create instance with firstName = "testFirstName" and lastName = "testLastName"
  • create instance with firstName = "123" and lastName = "123"
  • create instance with firstName = 12 and lastName = 123
  • create instance with firstName = null and lastName = null

Is this considered to be a test case of a unit testing of a classs?

Do i understand concept of testing properly?

Bear in mind that this is just a school project and all i want are test cases not actuall tests.

Aucun commentaire:

Enregistrer un commentaire