microcks-cli icon indicating copy to clipboard operation
microcks-cli copied to clipboard

Add unit tests for existing code

Open Harsh4902 opened this issue 9 months ago • 5 comments

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

Harsh4902 avatar Mar 21 '25 06:03 Harsh4902

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 avatar Mar 28 '25 06:03 Rupam-It

@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.

Harsh4902 avatar Mar 28 '25 18:03 Harsh4902

@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.

Harsh4902 avatar Apr 01 '25 16:04 Harsh4902

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.

Rupam-It avatar Apr 02 '25 13:04 Rupam-It

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:

github-actions[bot] avatar May 03 '25 00:05 github-actions[bot]