connell-class / revassess

this is a trial repo for making a template for the revature assessment
2 stars 11 forks source link

JUnit test "Answer4Tests" in tier 3 passes when an exception is thrown in the unit test #51

Open ghost opened 4 years ago

ghost commented 4 years ago

Describe the bug When an exception is thrown in the unit test it skips the assertion and the unit test passes by default. This was discovered when an exception was thrown when the unit test tried to execute a callable statement with and empty string ("") as the procedure name.

To Reproduce Steps to reproduce the behavior:

  1. Generate a repository from the template repository.
  2. Clone the generated repository
  3. Complete tier 1
  4. Complete tier 2
  5. Checkout branch to begin working on tier 3
  6. Before creating the database and filling out the credentials. Run the JUnit test "Answer4Tests". (A "java.sql.SQLException" will be thrown when it attempts to execute the callable statement, because it cannot connect to the database.)
  7. (Optionally) fill out the database credentials in the ConnectionUtil.java file and leave an empty string ("") for the "TIER_3_PROCEDURE_NAME" variable. (This will produce an exception when the unit test attempts to execute callable statement and does not have a valid name for the procedure name.)

Expected behavior When the JUnit test "Answer4Tests" is run without the credentials to a database a "java.sql.SQLException" will be thrown because it cannot connect to the database. This will cause the "Answer4Tests" unit test to handle an exception and skip or bypass the assertion and it will pass by default.

Screenshots N/A

Desktop (please complete the following information):

Additional context Possibly look into using Assert.fail(...) in the catch block.