Skip to content

Comments

Created test cases to bring JCodeAnalyzer, JavaAnalysis, and JavaSitter to 90% test coverage #75

Merged
rahlk merged 12 commits intocodellm-devkit:mainfrom
rofrano:fix-testcases
Jan 27, 2025
Merged

Created test cases to bring JCodeAnalyzer, JavaAnalysis, and JavaSitter to 90% test coverage #75
rahlk merged 12 commits intocodellm-devkit:mainfrom
rofrano:fix-testcases

Conversation

@rofrano
Copy link
Collaborator

@rofrano rofrano commented Jan 23, 2025

Description

This intention of this work is to increase overall test coverage for CLDK. It is still a work in progress but this first PR brings the overall test coverage from 35% to 58%, and for the initial targeted classes up to 90%+. In the process several defects were discovered which will be documented in this separate Issue: Defects uncovered while bringing test coverage for JCodeAnalyzer, JavaAnalysis, and JavaSitter up to 90% #74

Made the following changes:

  • Created test cases for JCodeAnalyzer to increase coverage from 32% to 91%
  • Created test cases for JavaAnalyzer to increase coverage from 38% to 90%
  • Created test cases for JavaSitter to increase coverage from 30% to 90%
  • Regenerated the slim analysis.json file from the DayTrader 8 v1.2 source code so that the test code and json are in sync.
  • Added a new test fixture that returns the contents of the slim analysis.json file to be used in Mocking
  • Added daytrader8-1.2.zip to the repo and modified PyTest fixture to not delete the file so that test won't fail if it can't be downloaded
  • Renamed JavaAnalysis class filename from java.py to java_analysis.py to be PEP8 compliance
  • Renamed JavaSitter class filename from javasitter.py to java_sitter.py to be PEP8 compliant

TODOs

16 of the test cases currently fail due to defects in the code but many can be traced back to the same error in underlying libraries so they should be easy to fix.

Here is the list of the failures which can be see by running: pytest:

Required test coverage of 50% reached. Total coverage: 57.62%
========================================================= short test summary info ==========================================================
FAILED tests/analysis/java/test_java_analysis.py::::It should return the callers - TypeError: JavaSitter.get_calling_lines() missing 1 required positional argument: 'is_target_method_a_constructor'
FAILED tests/analysis/java/test_java_analysis.py::::It should return the callees - TypeError: JavaSitter.get_calling_lines() missing 1 required positional argument: 'is_target_method_a_constructor'
FAILED tests/analysis/java/test_java_analysis.py::::It should return the constructors for a class - AssertionError: assert 18 == 2
FAILED tests/analysis/java/test_java_analysis.py::::It should return the nested classes for a class - assert 0 == 1
FAILED tests/analysis/java/test_java_analysis.py::::It should return the class call graph - TypeError: JavaSitter.get_calling_lines() missing 1 required positional argument: 'is_target_method_a_constructor'
FAILED tests/analysis/java/test_java_analysis.py::::It should remove all comments - NotImplementedError: Support for this functionality has not been implemented yet.
FAILED tests/analysis/java/test_java_analysis.py::::It should return methods with annotations - NotImplementedError: Support for this functionality has not been implemented yet.
FAILED tests/analysis/java/test_java_analysis.py::::It should return test methods - NotImplementedError: Support for this functionality has not been implemented yet.
FAILED tests/analysis/java/test_java_analysis.py::::It should return calling lines - AttributeError: 'JCodeanalyzer' object has no attribute 'get_calling_lines'
FAILED tests/analysis/java/test_java_analysis.py::::It should return calling targets - AttributeError: 'JCodeanalyzer' object has no attribute 'get_call_targets'
FAILED tests/analysis/java/test_java_sitter.py::::It should return the superclass name - AssertionError: assert '' == 'AbstractSequentialList'
FAILED tests/analysis/java/test_java_sitter.py::::It should safely ascend the node tree - ValueError: Node has no parent.
FAILED tests/analysis/java/test_jcodeanalyzer.py::::It should return all of the callers - TypeError: JavaSitter.get_calling_lines() missing 1 required positional argument: 'is_target_method_a_constructor'
FAILED tests/analysis/java/test_jcodeanalyzer.py::::It should return all of the callees - TypeError: JavaSitter.get_calling_lines() missing 1 required positional argument: 'is_target_method_a_constructor'
FAILED tests/analysis/java/test_jcodeanalyzer.py::::It should return all of the nested classes for a class - assert 0 == 1
FAILED tests/analysis/java/test_jcodeanalyzer.py::::It should return the call graph using the symbol table - TypeError: JavaSitter.get_calling_lines() missing 1 required positional argument: 'is_target_method_a_constructor'
================================================ 16 failed, 73 passed in 408.01s (0:06:48) =================================================

Signed-off-by: John Rofrano <johnnyroy@johnrofrano.com>
Signed-off-by: John Rofrano <johnnyroy@johnrofrano.com>
Signed-off-by: John Rofrano <johnnyroy@johnrofrano.com>
Signed-off-by: John Rofrano <johnnyroy@johnrofrano.com>
Signed-off-by: John Rofrano <johnnyroy@johnrofrano.com>
Signed-off-by: John Rofrano <johnnyroy@johnrofrano.com>
Signed-off-by: John Rofrano <johnnyroy@johnrofrano.com>
Signed-off-by: John Rofrano <johnnyroy@johnrofrano.com>
Signed-off-by: John Rofrano <johnnyroy@johnrofrano.com>
Signed-off-by: John Rofrano <johnnyroy@johnrofrano.com>
Signed-off-by: John Rofrano <johnnyroy@johnrofrano.com>
@rofrano rofrano requested a review from rahlk January 23, 2025 21:54
@rahlk rahlk merged commit 3b44af7 into codellm-devkit:main Jan 27, 2025
1 check passed
@rofrano rofrano deleted the fix-testcases branch January 27, 2025 18:51
@rahlk rahlk added the test Added new tests label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Added new tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants