Skip to content

Conversation

@matthieu-vergne
Copy link
Contributor

@matthieu-vergne matthieu-vergne commented Oct 20, 2018

Since there is no automated test, I took the freedom to create a functional test with Cucumber (it runs through JUnit). These tests are nice to show how the lib satisfies some high level requirements. Here is the one I wrote:

  Scenario: Retrieve lambda in method
    Given I have the class "LambdaTest" with code:
      """
      public class LambdaTest {
       public void methodA() {
        Runner r = () -> methodB();
        r.run();
       }
       
       public void methodB() {}
      }
      """
    When I run the analyze
    Then the result should contain:
      """
      M:LambdaTest:lambda$methodA$0() (M)LambdaTest:methodB()
      """

To make it work, I needed to compile the code of the scenario to produce the JAR to analyze. This compiler and the test are the main outcomes of this pull request, and new scenarios can now be easily produced to properly test other parts of the lib.

Of course, the point is not simply to spend time testing the lib. The point was for me to set up a basis in order to investigate a nasty bug. Indeed, nested lambdas are not properly managed: we miss the link between the parent method and the lambda (...:lambda$null$0(...)), so the call graph is broken. What I did here allowed me to make another scenario for that, so I can properly reproduce it and investigate. But it will come in another pull request when I solve it.

@gousiosg
Copy link
Owner

Fantastic PR, thanks!

@gousiosg gousiosg merged commit e191b82 into gousiosg:master Oct 23, 2018
@matthieu-vergne
Copy link
Contributor Author

You're welcome. Always better with automated tests.

@matthieu-vergne matthieu-vergne deleted the feature/functional_testing branch October 24, 2018 21:05
pombredanne pushed a commit to pombredanne/java-callgraph that referenced this pull request May 29, 2024
* Progress on comparison tool for RQ1

* Progress on comparison tool for RQ1

* Progress on comparison tool for RQ1

* Progress on comparison tool for RQ1

* Progress on comparison tool for RQ1

* Fix issue with copying output with subprojects and timestamps

* Add rq1 experiment bash and python script

* Updated rq1 experiment bash and python script

* Updated rq1 experiment bash and python script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants