Skip to content
Antonio Mateo edited this page Dec 23, 2021 · 2 revisions

Theoretical Exercise 3

This exercise was done ONLY by: Antonio Mateo Francés.

First of all, after having read the statement, I have identified the boundary values, as an interval, of the problem. As in both tables, we have the same kind of intervals: this helps us in defining the boundary values, as we are going to see.

Boundary Values:

We can imagine an interval in order to do this approach:

  • [0,10) U[10,35) U [35,50) U [50,70) U [70,90) U [90.100]

To do the testing cases, I have selected these values:

  • -10, and also 101, intuitively chosen, in order to check that InvalidException is thrown
  • 0, in order to enter the first interval
  • 10, in order to enter the second interval
  • 35, in order to enter the third interval
  • 50, in order to enter the fourth interval
  • 70, in order to enter the fifth interval
  • 90, in order to enter the sixth interval

Error Guessing Values:

As of the development of the program, I have detected by intuition some values that may raise an exception (InvalidException). Those values are shown above: -10, and 101, to represent the outsides of our work environment. They could be any value from (-∞, 0) U (100, ∞). As an example, I took those. Also I thought about the possibility of putting string values inside the test cases, but because of limited time, I have not properly tested it. But it should raise NumberFormatException, which is an exception already defined in the Java API.

Explanation of method developed – isCertifiable():

Every sub characteristic will have a concrete method putting a value corresponding with the tables. All conditions required for the obtention of values are inside this method. As to determine if a program is certifiable or not, we have the isCertifiable() boolean method, that compares with the 3rd table of the problem if a program, given the values calculated from previous tables, will be returning true or false. In my case I have put a print() that gets also the quality obtained if the program is certified, and returning a true. If a program cannot be certified, because of a bad value or not so high value, we manage it with the created exception InvalidException, that shows: “EXCEPTION: You put a value outside the intervals!!”, and then returning the result of certification, which is false due to the initialization of the boolean variable. In order to catch the exception everything would be surrounded with a try-catch block.

Getting Functional Completeness (f_comp):

This corresponds to the very first part of the method. We have a set of conditions, according to the intervals said in the tables. This intervals remain the same for both tables, so the explanation above is valid. As of the interval defined above, we can determine that every value inside it, would be properly managed, as the tables in the statement 3 show. Outsider values will be treated as a non-valid value, with a concrete exception class I created, called InvalidException. This exception will print a message invalidating this measure of quality, putting it to –1 and returning false.

  • If value greater or equal than 0 AND smaller than 10, then f_comp = 0.
  • Else If value greater or equal than 10 AND smaller than 35, then f_comp = 1.
  • Else If value greater or equal than 35 AND smaller than 70, then f_comp = 2.
  • Else If value greater or equal than 70 AND smaller than 90, then f_comp = 3.
  • Else If value greater or equal than 90 AND smaller or equal to 100, then f_comp = 4.
  • Else: f_comp = -1, throw InvalidException

Getting Functional Correctness (f_corr):

This corresponds to the second part of the method. We have a set of conditions, according to the intervals said in the tables.

As of the interval defined above, we can determine that every value inside it, would be properly managed, as the tables in the statement 3 show. On the other hand, outsider values will be treated as a non-valid value, with a concrete exception class I created, called InvalidException. This exception will print a message invalidating this measure of quality, putting it to –1 and returning false.

  • If value greater or equal than 0 AND smaller than 10, then f_corr = 0.
  • Else If value greater or equal than 10 AND smaller than 50, then f_corr = 1.
  • Else If value greater or equal than 50 AND smaller than 70, then f_corr = 2.
  • Else If value greater or equal than 70 AND smaller than 90, then f_corr = 3.
  • Else If value greater or equal than 90 AND smaller or equal to 100, then f_corr = 5.
  • Else: f_corr = -1, throw InvalidException

Getting Functional Appropriateness (f_appr):

This corresponds to the third part of the method. We have a set of conditions, according to the intervals said in the tables.

As of the interval defined above, we can determine that every value inside it, would be properly managed, as the tables in the statement 3 show. On the other hand, outsider values will be treated as a non-valid value, with a concrete exception class I created, called InvalidException. This exception will print a message invalidating this measure of quality, putting it to –1 and returning false.

  • If value greater or equal than 0 AND smaller than 10, then f_appr = 0.
  • Else If value greater or equal than 10 AND smaller than 50, then f_appr = 2.
  • Else If value greater or equal than 50 AND smaller than 70, then f_appr = 3.
  • Else If value greater or equal than 70 AND smaller than 90, then f_appr = 4.
  • Else If value greater or equal than 90 AND smaller or equal to 100, then f_appr = 5.
  • Else: f_appr = -1, throw InvalidException

After getting the 3 attributes of the first table, we compute the minimum of them on next part.

Getting Functional Suitability(functionalSuitability):

This corresponds to the fourth part of the method. We compute the minimum with the java.Math’s function min(). After computing all operations, we will get that minimum value

  • functionalSuitability = min(f_comp, f_corr)
  • functionalSuitability = min(functionalSuitability, f_appr)

Getting Modularity (modularity):

This corresponds to the fifth part of the method. We have a set of conditions, according to the intervals said in the tables. As of the interval defined above, we can determine that every value inside it, would be properly managed, as the tables in the statement 3 show. On the other hand, outsider values will be treated as a non-valid value, with a concrete exception class I created, called InvalidException. This exception will print a message invalidating this measure of quality, putting it to –1 and returning false.

  • If value greater or equal than 0 AND smaller than 10, then modularity = 0.
  • Else If value greater or equal than 10 AND smaller than 35, then modularity = 1.
  • Else If value greater or equal than 35 AND smaller than 70, then modularity = 2.
  • Else If value greater or equal than 70 AND smaller than 90, then modularity = 3.
  • Else If value greater or equal than 90 AND smaller or equal to 100, then modularity = 4.
  • Else: modularity = -1, throw InvalidException

Getting Reusability (reusability):

This corresponds to the sixth part of the method. We have a set of conditions, according to the intervals said in the tables. As of the interval defined above, we can determine that every value inside it, would be properly managed, as the tables in the statement 3 show. On the other hand, outsider values will be treated as a non-valid value, with a concrete exception class I created, called InvalidException. This exception will print a message invalidating this measure of quality, putting it to –1 and returning false.

  • If value greater or equal than 0 AND smaller than 10, then reusability = 0.
  • Else If value greater or equal than 10 AND smaller than 35, then reusability = 1.
  • Else If value greater or equal than 35 AND smaller than 70, then reusability = 2.
  • Else If value greater or equal than 70 AND smaller than 90, then reusability = 3.
  • Else If value greater or equal than 90 AND smaller or equal to 100, then reusability = 5.
  • Else: reusability = -1, throw InvalidException

Getting Analyzability (analyzability):

This corresponds to the seventh part of the method. We have a set of conditions, according to the intervals said in the tables. As of the interval defined above, we can determine that every value inside it, would be properly managed, as the tables in the statement 3 show. On the other hand, outsider values will be treated as a non-valid value, with a concrete exception class I created, called InvalidException. This exception will print a message invalidating this measure of quality, putting it to –1 and returning false.

  • If value greater or equal than 0 AND smaller than 10, then analyzability = 0.
  • Else If value greater or equal than 10 AND smaller than 35, then analyzability = 1.
  • Else If value greater or equal than 35 AND smaller than 70, then analyzability = 2.
  • Else If value greater or equal than 70 AND smaller than 90, then analyzability = 3.
  • Else If value greater or equal than 90 AND smaller or equal to 100, then analyzability = 5.
  • Else: analyzability = -1, throw InvalidException

Getting Modifiability (modificable):

This corresponds to the eighth part of the method. We have a set of conditions, according to the intervals said in the tables. As of the interval defined above, we can determine that every value inside it, would be properly managed, as the tables in the statement 3 show. On the other hand, outsider values will be treated as a non-valid value, with a concrete exception class I created, called InvalidException. This exception will print a message invalidating this measure of quality, putting it to –1 and returning false.

  • If value greater or equal than 0 AND smaller than 10, then modificable = 0.
  • Else If value greater or equal than 10 AND smaller than 35, then modificable = 1.
  • Else If value greater or equal than 35 AND smaller than 50, then modificable = 2.
  • Else If value greater or equal than 50 AND smaller than 70, then modificable = 3.
  • Else If value greater or equal than 70 AND smaller than 90, then modificable = 5.
  • Else If value greater or equal than 90 AND smaller or equal to 100, then modificable = 5.
  • Else: modularity = -1, throw InvalidException

Getting Testability (testable):

This corresponds to the nineth part of the method. We have a set of conditions, according to the intervals said in the tables. As of the interval defined above, we can determine that every value inside it, would be properly managed, as the tables in the statement 3 show. On the other hand, outsider values will be treated as a non-valid value, with a concrete exception class I created, called InvalidException. This exception will print a message invalidating this measure of quality, putting it to –1 and returning false.

· If value greater or equal than 0 AND smaller than 10, then testable = 0. · Else If value greater or equal than 10 AND smaller than 50, then testable = 1. · Else If value greater or equal than 50 AND smaller than 70, then testable = 2. · Else If value greater or equal than 70 AND smaller or equal to 100, then testable = 4. · Else: modularity = -1, throw InvalidException

After all of this we get the Maintainability value

Getting Maintainability (maintainability):

This corresponds to the tenth part of the method. We compute the minimum with the java.Math’s function min(). After computing all operations, we will get that minimum value for maintainability

  • min_first = min(modularity, reusability)
  • min_second = min(analyzability, modifiability)
  • maintainability = min(min_first, min_second)
  • maintainability = min(maintainability, testable)

After getting all values required to compute if the program is certified. We get into the last part of the isCertifiable() method, which is to know whether or not a program is certified, and if so, the quality level obtained. We have reached the last part of the method.

Getting the certification, and if true, the quality measure (certified, quality):

Last part of the method. We have a set of conditions, according to the intervals said in the final Suitability-Maintainability table. We are pretty much interested on the situation when functionalSuitability is equal or greater than 3. Values that have a functionalSuitability less than 3, will return false with a print() saying “Program NOT certified”.

  • If functionalSuitability equal to 3 AND maintainability greater or equal to 3 , then certified = true, quality=3.
  • Else If functionalSuitability equal to 4 AND maintainability less or equal to 3, then certified = true, quality = 3.
  • Else If functionalSuitability equal to 4 AND maintainability equal to 4, then certified = true, quality = 4.
  • Else: print(“Program NOT certified”), certified = false, quality = -1 (this last will not be shown)

NOTE: If we got an exception from before we will go into the catch block, also returning false, showing the exception message, and showing also “Program not certified”.

Testing:

In order to develop the test cases, I have created a class called CertificationTest.java. Inside it, I have defined many test cases in order to test the program, but most of them were done just to get more coverage, to get the at least 75% required. With just one test valuating as true the certification of a program with concrete values, and another one that gets false, it would be enough to determine that, at least, the test suite is useful. Beware this does not mean that it won’t have failures!.

Now, a table putting some test cases performed. For simplicity I joined 1 and 2 tables of testing, joining both on only one. I have used each use strategy: take some important values, and gotten a good coverage, more than 75%, which was the minimum required. Also I took into account the error-guessing values said above, even though I could not implement it.

tablita_tests

If you cannot see well the picture click here

Also, some information about this test class, with the tests done

some_tests

If you cannot see well the picture click here

The first corresponds to a test that certificates a program with that parameters put. The second is the inverse: returns false if that values are set to a program certification. Last one refers to the case we put values outside the intervals we established before: the exception developed, InvalidException, will be raised, and we finish the test returning false.

Report:

Thanks to the Jacoco and Surefire plugins, reports are automatically generated, so we can know what happened during the tests. In order to see everything in detail, go to Exercise_3/target/site/index.html has all the info, go to Project Report -> JaCoCo, Surefire

While looking at this picture we can see a bit what happened:

txt_eclipse

If you cannot see well the picture click here

These results indicate if the certificate would be conceded, if the quality is equal or greater than 3. If not, it would not conceed it, printing the program is NOT certified and returning false. If it was an exception, the test finalizes printing we put a value outside the intervals, printing the program is NOT certified at all, and returning false (no certification)

Also when we run the jUnit tool to get the coverage, we get some results of the tests we have done:

foto_junit1

foto_junit2

If you cannot see well the pictures click here and here

*NOTE: Again, in order to see in more detail this testing, go to Exercise_3/target/site/index.html