Codegass opened a new issue, #6666:
URL: https://github.com/apache/cloudstack/issues/6666

   ##### ISSUE TYPE
    * Improvement Request
   ##### COMPONENT NAME
   unit-test
   ##### OS / ENVIRONMENT
   N/A
   ##### SUMMARY
   I noticed that [ testCreateSuccess 
](https://github.com/apache/cloudstack/blob/6d11e2faa99a27bcb3b124f30a87748c91871514/api/src/test/java/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java#L66)
 does not contain assert statements. This is confusing to me since I do not 
know whether this test case pass or fail. In my understanding, 
`testCreateSuccess` is testing `scaleVMCmd.execution()` function to make sure 
the VM is created successfully. But it just ends there, not checking any of the 
running results. 
   
   The `scaleVMCmd.execution()` function has defined multiple exceptions and 
mocked all the values getting functions, but the test case does not have `throw 
Exception` or `try-catch` structure for the `scaleVMCmd.execution()` . Also, 
how many times the mocked functions are called are still not checked.
   <!--
   When I am exploring the source code of the project, I noticed that there is 
a test case that doesn’t have a proper Assertion at the end of it:
   
   * [ testCreateSuccess 
](https://github.com/apache/cloudstack/tree/main/src/test/java/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java#L66)
 is testing `scaleVMCmd.execution()` function to make sure the VM is created 
successfully. But it just ends there, not checking any of the running results.
   
   This case really confused me, I noticed that the `scaleVMCmd.execution()` 
function has defined multiple exceptions and mocked all the values getting 
functions, but how many times the mocked functions are called are still not 
checked.
   -->
   
   I would suggest refactoring the cases by adding execution time verifications 
with Mockito. The goal is to make the test condition more explicit and 
reusable. 
   
   if you think this makes sense, I would be more than happy to try the 
refactoring and submit a PR.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to