mcptools icon indicating copy to clipboard operation
mcptools copied to clipboard

Tests aren't testing the implementation

Open ayakutt opened this issue 1 year ago • 3 comments

main_test.go currently doesn't seem to directly interact with the implementation code. So, changes to the actual code cannot be caught by the existing tests, which reduces their effectiveness.

It might be worth revisiting the tests to ensure they properly validate the implementation.

ayakutt avatar Mar 29 '25 05:03 ayakutt

Hi, @ayakut16. Could you test on onurravli:fix/tests branch?

onurravli avatar Apr 03 '25 21:04 onurravli

Since I opened this issue, the tests have been updated and there is now some interaction with the actual implementation. However overall test coverage of this repo is a bit concerning imo:

alperen ➜  mcptools git:(master) go test -cover ./...
ok      github.com/f/mcptools/cmd/mcptools      (cached)        coverage: 8.6% of statements
        github.com/f/mcptools/pkg/alias         coverage: 0.0% of statements
        github.com/f/mcptools/pkg/client                coverage: 0.0% of statements
ok      github.com/f/mcptools/pkg/jsonutils     (cached)        coverage: 45.3% of statements
        github.com/f/mcptools/pkg/mock          coverage: 0.0% of statements
        github.com/f/mcptools/pkg/proxy         coverage: 0.0% of statements
        github.com/f/mcptools/pkg/transport             coverage: 0.0% of statements

Regarding onurravli:fix/tests, I don't think it addresses this issue—it actually reduces the test coverage for mcptools to 0%. That said, it does improve things somewhat by calling proxy.NewProxyServer(). However, I think the best approach would be to call that function from tests within the proxy package, which currently don't exist.

alperen ➜  mcptools git:(fix-tests-onur) go test -cover ./...
ok      github.com/f/mcptools/cmd/mcptools      0.995s  coverage: 0.0% of statements
        github.com/f/mcptools/pkg/alias         coverage: 0.0% of statements
        github.com/f/mcptools/pkg/client                coverage: 0.0% of statements
ok      github.com/f/mcptools/pkg/jsonutils     (cached)        coverage: 45.3% of statements
        github.com/f/mcptools/pkg/mock          coverage: 0.0% of statements
        github.com/f/mcptools/pkg/proxy         coverage: 0.0% of statements
        github.com/f/mcptools/pkg/transport             coverage: 0.0% of statements

ayakutt avatar Apr 03 '25 22:04 ayakutt

This can be closed now, the tests still needs to be improved imo but now they do interact the implementation.

ayakutt avatar Apr 06 '25 20:04 ayakutt