Biopesticide (2).pptx .This slides helps to know the different types of biop...
Have Java Production Methods Co-Evolved With Test Methods Properly?: A Fine-Grained Repository- Based Co-Evolution Analysis
1. Have Java Production Methods
Co-Evolved With Test Methods
Properly?:
A Fine-Grained Repository-
Based Co-Evolution Analysis
Tenma Kita*1
Hirohisa Aman*1
Sousuke Amasaki*2
Tomoyuki Yokogawa*2
Minoru Kawahara*1
SEAA2022 (C) 2022 Hirohisa Aman
*1) Ehime University,
Matsuyama, Ehime, Japan
*2) Okayama Prefectural Univ.,
Soja, Okayama, Japan
0
2. Overview
Aim
To detect Java methods that might not be properly
tested through code evolutions
Method
We examine co-evolution relationships
(logical couplings) of production code with test code,
using a fine-grained code repository;
We propose a metric for evaluating their logical links
Result
We empirically proved that most Java methods (98%
on average) have co-evolved with test methods, but
some have not; our metric detected some risky ones
SEAA2022 (C) 2022 Hirohisa Aman 1
3. Outline
Background & Related Work
Logical Coupling Between Production &
Test Methods
Case Study
Conclusion & Future Work
SEAA2022 (C) 2022 Hirohisa Aman 2
4. Outline
Background & Related Work
Logical Coupling Between Production &
Test Methods
Case Study
Conclusion & Future Work
SEAA2022 (C) 2022 Hirohisa Aman 3
5. Co-Evolution
Between Production and test code
A set of source code (repository) includes not
only the production code but the test code
SEAA2022 (C) 2022 Hirohisa Aman 4
src
main
test
ConnectionStateManager.java
TestConnectionStateManager.java
…
…
update
update
When developers update a production code,
they should update or add the test code too
Co‐Evolution
6. Logical Coupling
A successful co-evolution between production
and test code form a logical coupling
Our focus is on a poor logical coupling
Such a production code may have little or no
corresponding test code
SEAA2022 (C) 2022 Hirohisa Aman 5
commits
P1 T1 P1 T1 P1 T2
new code
creation
functionality
change
bugfix
P1
change
T1 T2
change
logical
coupling
7. Related Work (1/2)
Luben et al.[9] emphasized the successful
maintenance of test cases in test-driven
development
They analyzed logical couplings between
Java production classes and JUnit test
classes for a successful maintenance
SEAA2022 (C) 2022 Hirohisa Aman 6
Although it is a valuable previous study, the
analysis is at class-level and coarse-grained
To analyze those relationships from a finer-
grained point of view, we utilize a method-
level code repository in this study
8. Related Work (2/2)
Marsavina et al.[5] & Vidacs and Pinzger[10]
performed a fine-grained code change analysis
to extract co-evolution patterns
Ex. “A production class addition/removal tends to
cause a test class addition/removal”
SEAA2022 (C) 2022 Hirohisa Aman 7
Those studies yield profound insights into co-
evolution relationships
However, their main focuses were on the co-
evolution patterns, but poorly tested code (poor
logical coupling) was out of their analysis;
We focus on such a poor logical coupling to
detect a problematic code
9. Outline
Background & Related Work
Logical Coupling Between Production &
Test Methods
Case Study
Conclusion & Future Work
SEAA2022 (C) 2022 Hirohisa Aman 8
10. Analysis Granularity: Method
As a file-level analysis seems to be coarse
and insufficient, we will trace logical
couplings at method level
To this end, we utilize a fine-grained code
repository, FinerGit[8]
FinerGit can convert a file-level normal Git
repository to a method-level Git repository
In the converted repository, each Java method
corresponds to each file
We can easily trace a method-level change history
through Git commands
SEAA2022 (C) 2022 Hirohisa Aman 9
11. Logical Coupling & Its Strength
For a relation 𝒑 𝒕, the following
confidence value presents its strength of link:
SEAA2022 (C) 2022 Hirohisa Aman 10
When developers change a Java method
𝒑 at a commit, they tend to also change
another method 𝒕 at the same commit
𝒑 𝒕
𝒑 𝒕) =
𝒑 𝒕
𝒑
𝜎
𝜎(x) is # of
x’s changes
12. Two or more test methods may
correspond to a production method
The confidence value corresponds to a
conditional probability P( 𝒕 | 𝒑)
Similarly, we can consider probability that at
least one test method is changed as
SEAA2022 (C) 2022 Hirohisa Aman 11
0.4
0.3 The probability that
both 𝑚 and 𝑚
are not changed
P( 𝒕 𝒕 | 𝒑) P( 𝒕 𝒕 | 𝒑)
13. Proposed metric:
Some production methods might be linked to
other production methods, and the latter
ones are tested, i.e., indirect test links
We propose a novel metric, , to cover
such indirect logical couplings as well
SEAA2022 (C) 2022 Hirohisa Aman 12
0.4
0.3
0.1
0.7
0.2
0.3
𝑐𝑜𝑛𝑓 0.58
𝑐𝑜𝑛𝑓 0.73
𝑇𝑐𝑜𝑛𝑓
1 1 0.2 · 0.58 · 1 0.3 · 0.73
1 0.884 · 0.781
0.310
𝑇𝑐𝑜𝑛𝑓 0.310
14. What evaluates?
The value of a production method
evaluates the likelihood that the production
method co-evolves with one or more test
methods in either direct or indirect manners
A production method with a low
value might be problematic as it has not
been co-evolved with test methods
SEAA2022 (C) 2022 Hirohisa Aman 13
15. Outline
Background & Related Work
Logical Coupling Between Production &
Test Methods
Case Study
Conclusion & Future Work
SEAA2022 (C) 2022 Hirohisa Aman 14
16. Studied Projects
We conducted a case study using ten Apache
top-level projects to demonstrate how
helps detect the problematic Java methods
SEAA2022 (C) 2022 Hirohisa Aman 15
17. Results(1/2): Curator project
Distribution of values in the Curator project
SEAA2022 (C) 2022 Hirohisa Aman 16
mean 0.9948
𝑇𝑐𝑜𝑛𝑓
0.5 0.5 0.999 ≃ 1
0.43% 0.64% 𝟗𝟖. 𝟗𝟑%
Most production methods
(over 98%) in this project
have co-evolved with at
least one test method
18. Results(2/2): Other Projects
All other projects showed similar results
SEAA2022 (C) 2022 Hirohisa Aman 17
Fineract Flume Maven Parquet
PDFBox Ranger RocketMQ Shiro
Zookeeper
𝑇𝑐𝑜𝑛𝑓 𝐚𝐥𝐥 𝐩𝐫𝐨𝐣𝐞𝐜𝐭𝐬
0.5 0.5 0.999 ≃ 1
0.67% 1.33% 𝟗𝟖. 𝟎𝟎%
19. Discussions(1/4)
As a result, we found that 98% of production
methods have , i.e., they have co-
evolved with one or more test methods
Nonetheless, we also found some production
methods with low values
They included simple accessor methods like:
Indeed, the above simple method does not need to be
carefully tested …
SEAA2022 (C) 2022 Hirohisa Aman 18
𝑇𝑐𝑜𝑛𝑓 0
20. Discussions(2/4)
So, we filtered out the following methods:
It has appeared in the commit history only once
It has the lowest cyclomatic complexity (=1)
Even if we filtered simple methods, there are
some production methods with
SEAA2022 (C) 2022 Hirohisa Aman 19
21. Discussions(3/4)
An example of
production method
with
LOC = 44
Cyclomatic complexity = 7
Number of commits = 2
SEAA2022 (C) 2022 Hirohisa Aman 20
Although the developers
might prepare test code for
this method independently,
it is worth it to detect such
a method and alert it
22. Discussions(4/4)
Notice that a low value does not
directly indicate the poor quality
Nonetheless, can detect the methods
that have not been successfully co-evolved
with test methods
By alerting such potentially problematic
production methods to the developers,
can contribute somewhat to the
successful software evolution
SEAA2022 (C) 2022 Hirohisa Aman 21
23. Threats to Validity
Construct Validity:
There might be a delayed logical coupling
Internal Validity:
Some non-functional changes (refactoring or
comment changes) might become noise data
External Validity:
We studied only ten Java projects
It is an impactful factor if the project adopt the
test-driven development or not
SEAA2022 (C) 2022 Hirohisa Aman 22
24. Outline
Background & Related Work
Logical Coupling Between Production &
Test Methods
Case Study
Conclusion & Future Work
SEAA2022 (C) 2022 Hirohisa Aman 23
25. Conclusion
We focused on the co-evolution (logical
coupling) between Java production and test
methods
We proposed as a metric for evaluating
how a Java production method has properly
co-evolved with test methods
A case study showed that
Most methods (98% on average) had been co-
evolved successfully
helps us to detect some potentially
problematic methods as well
SEAA2022 (C) 2022 Hirohisa Aman 24
26. Future Work
A validation study of by getting
feedback from the developers
An empirical study of relationship between
value and the overlooked faults
Further analyses focusing on the code change
details and delayed logical couplings where
the test method’s commit occurs after the
production one’s commit
SEAA2022 (C) 2022 Hirohisa Aman 25