File size: 6,156 Bytes
56cdf43
4c57758
 
56cdf43
4c57758
 
 
 
 
 
 
 
 
 
 
e096ba6
4c57758
 
e096ba6
4c57758
e096ba6
4c57758
e096ba6
 
4c57758
 
e096ba6
4c57758
e096ba6
4c57758
e096ba6
 
4c57758
 
e096ba6
4c57758
e096ba6
4c57758
e096ba6
 
4c57758
 
e096ba6
4c57758
e096ba6
4c57758
e096ba6
 
4c57758
 
e096ba6
4c57758
e096ba6
4c57758
e096ba6
 
4c57758
 
e096ba6
4c57758
e096ba6
4c57758
e096ba6
 
4c57758
 
e096ba6
4c57758
e096ba6
4c57758
e096ba6
 
4c57758
 
e096ba6
4c57758
e096ba6
4c57758
e096ba6
 
4c57758
 
e096ba6
4c57758
e096ba6
4c57758
e096ba6
 
 
 
 
 
 
 
 
4c57758
 
 
 
 
 
 
 
e096ba6
4c57758
 
e096ba6
4c57758
e096ba6
4c57758
e096ba6
 
 
 
 
 
 
 
 
f90a46e
 
 
 
56cdf43
f90a46e
 
 
 
 
 
3b904e7
f90a46e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
---
language:
- en
license: mit
task_categories:
- text-generation
configs:
- config_name: fm
  data_files:
  - split: train
    path: data/fm/train-*
  - split: test
    path: data/fm/test-*
  - split: validation
    path: data/fm/validation-*
- config_name: fm_indented
  data_files:
  - split: train
    path: data/fm_indented/train-*
  - split: test
    path: data/fm_indented/test-*
  - split: validation
    path: data/fm_indented/validation-*
- config_name: fm+t
  data_files:
  - split: train
    path: data/fm+t/train-*
  - split: test
    path: data/fm+t/test-*
  - split: validation
    path: data/fm+t/validation-*
- config_name: fm+fc
  data_files:
  - split: train
    path: data/fm+fc/train-*
  - split: test
    path: data/fm+fc/test-*
  - split: validation
    path: data/fm+fc/validation-*
- config_name: fm+fc+t+tc
  data_files:
  - split: train
    path: data/fm+fc+t+tc/train-*
  - split: test
    path: data/fm+fc+t+tc/test-*
  - split: validation
    path: data/fm+fc+t+tc/validation-*
- config_name: fm+fc+c
  data_files:
  - split: train
    path: data/fm+fc+c/train-*
  - split: test
    path: data/fm+fc+c/test-*
  - split: validation
    path: data/fm+fc+c/validation-*
- config_name: fm+fc+c+t+tc
  data_files:
  - split: train
    path: data/fm+fc+c+t+tc/train-*
  - split: test
    path: data/fm+fc+c+t+tc/test-*
  - split: validation
    path: data/fm+fc+c+t+tc/validation-*
- config_name: fm+fc+c+m
  data_files:
  - split: train
    path: data/fm+fc+c+m/train-*
  - split: test
    path: data/fm+fc+c+m/test-*
  - split: validation
    path: data/fm+fc+c+m/validation-*
- config_name: fm+fc+c+m+t+tc
  data_files:
  - split: train
    path: data/fm+fc+c+m+t+tc/train-*
  - split: test
    path: data/fm+fc+c+m+t+tc/test-*
  - split: validation
    path: data/fm+fc+c+m+t+tc/validation-*
- config_name: fm+fc+c+m+f
  data_files:
  - split: train
    path: data/fm+fc+c+m+f/train-*
  - split: test
    path: data/fm+fc+c+m+f/test-*
  - split: validation
    path: data/fm+fc+c+m+f/validation-*
- config_name: fm+fc+c+m+f+t+tc
  data_files:
  - split: train
    path: data/fm+fc+c+m+f+t+tc/train-*
  - split: test
    path: data/fm+fc+c+m+f+t+tc/test-*
  - split: validation
    path: data/fm+fc+c+m+f+t+tc/validation-*
- config_name: t
  data_files:
  - split: train
    path: data/t/train-*
  - split: test
    path: data/t/test-*
  - split: validation
    path: data/t/validation-*
- config_name: t_indented
  data_files:
  - split: train
    path: data/t_indented/train-*
  - split: test
    path: data/t_indented/test-*
  - split: validation
    path: data/t_indented/validation-*
- config_name: t+tc
  data_files:
  - split: train
    path: data/t+tc/train-*
  - split: test
    path: data/t+tc/test-*
  - split: validation
    path: data/t+tc/validation-*
tags:
- unit test
- java
- code
---

## Dataset Description
Microsoft created the methods2test dataset, consisting of Java Junit test cases with its corresponding focal methods. 
It contains 780k pairs of JUnit test cases and focal methods which were extracted from a total of 91K
Java open source project hosted on GitHub.

This is an assembled version of the methods2test dataset. It provides convenient access to the different context levels based on the raw source code (e.g. newlines are preserved). The test cases and associated classes are also made available.

The mapping between test case and focal methods are based heuristics rules and Java developer's best practice.

More information could be found here:
- [methods2test Github repo](https://github.com/microsoft/methods2test)
- [Methods2Test: A dataset of focal methods mapped to test cases](https://arxiv.org/pdf/2203.12776.pdf)

## Dataset Schema
```
t: <TEST_CASE>
t_tc: <TEST_CASE> <TEST_CLASS_NAME>
fm: <FOCAL_METHOD>
fm_fc: <FOCAL_CLASS_NAME> <FOCAL_METHOD>
fm_fc_c: <FOCAL_CLASS_NAME> <FOCAL_METHOD> <CONTRSUCTORS>
fm_fc_c_m: <FOCAL_CLASS_NAME> <FOCAL_METHOD> <CONTRSUCTORS> <METHOD_SIGNATURES>
fm_fc_c_m_f: <FOCAL_CLASS_NAME> <FOCAL_METHOD> <CONTRSUCTORS> <METHOD_SIGNATURES> <FIELDS>
```

## Focal Context
- fm: this representation incorporates exclusively the source
code of the focal method. Intuitively, this contains the most
important information for generating accurate test cases for
the given method.
- fm+fc: this representations adds the focal class name, which
can provide meaningful semantic information to the model.
- fm+fc+c: this representation adds the signatures of the constructor methods of the focal class. The idea behind this
augmentation is that the test case may require instantiating
an object of the focal class in order to properly test the focal
method.
- fm+fc+c+m: this representation adds the signatures of the
other public methods in the focal class. The rationale which
motivated this inclusion is that the test case may need to
invoke other auxiliary methods within the class (e.g., getters,
setters) to set up or tear down the testing environment.
- fm+fc+c+m+f : this representation adds the public fields of
the focal class. The motivation is that test cases may need to
inspect the status of the public fields to properly test a focal
method.

![image/png](https://huggingface.co/datasets/andstor/methods2test/resolve/main/figure-1-focal-context.png)

 The different levels of focal contexts are the following:
```
T: test case
T_TC: test case + test class name
FM: focal method
FM_FC: focal method + focal class name
FM_FC_C: focal method + focal class name + constructor signatures
FM_FC_C_M: focal method + focal class name + constructor signatures + public method signatures
FM_FC_C_M_F: focal method + focal class name + constructor signatures + public method signatures + public fields
```

## Limitations
The original authors validate the heuristics by inspecting a
statistically significant sample (confidence level of 95% within 10%
margin of error) of 97 samples from the training set. Two authors
independently evaluated the sample, then met to discuss the disagreements. We found that 90.72% of the samples have a correct
link between the test case and the corresponding focal method

## Contribution
All thanks to the original authors.