Add unit tests for existing code
Reason/Context
- To ensure the quality of upcoming developments, we have to add unit tests for existing code.
Description
- Add unit tests for existing code.
- Related issue: #127
Implementation ideas
No response
hey @Harsh4902 , can you check this test file https://github.com/Rupam-It/microcks-cli/blob/issue130/cmd/help_command_test.go!
go test ./cmd -v
=== RUN TestHelpCommand_Execute
--- PASS: TestHelpCommand_Execute (0.00s)
PASS
ok github.com/microcks/microcks-cli/cmd 0.002s
if okk then i will add other files also !
@Rupam-It I looked at current command's files. Actually, It's not feasible to add test because we have all the functionality into the one function. So I think firstly we should take a look at this. Furthermore, we don't have to test commands, we have to test functionalities so, we don't need to test output of specific command.
@Rupam-It Any thought on this?
@Rupam-It I looked at current command's files. Actually, It's not feasible to add test because we have all the functionality into the one function. So I think firstly we should take a look at this. Furthermore, we don't have to test commands, we have to test functionalities so, we don't need to test output of specific command.
hey @Harsh4902 , Apologies for the delayed response! I just got around to reviewing your comment. Thanks for the feedback—I see your point about the Execute() function containing too much logic, making it hard to test.
I agree that we should first refactor the function to separate concerns, making it easier to test the core functionalities rather than just the CLI output. Here's what I propose: 1️⃣ Extract logic like argument parsing, API calls, and test result handling into separate functions. 2️⃣ Write unit tests for these functions individually. 3️⃣ Once the core functionalities are covered, we can evaluate if any minimal CLI-level testing is needed.
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
It will be closed in 30 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. Microcks is a Cloud Native Computing Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience :heart: