You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: "Verify an e-mail was sent (e.g. registration activation link, password reset)"
176
176
177
177
random_data: # 8 pts | once
178
-
done: false
178
+
done: true
179
179
description: "Generate random test data (e.g. random username, email) and use it in a test"
180
180
181
181
download_files: # 12 pts | once
182
182
done: false
183
183
description: "Download one or more files to a folder and verify they were saved"
184
184
185
185
config_file: # 6 pts | once
186
-
done: false
186
+
done: true
187
187
description: "Store test settings in an external file (e.g. .properties, .yml, or .env) and read them at runtime — things like base URL, username, password, browser type. No hardcoded values in your test code"
For JAVA we can use Jacoco to measure code coverage, we have to extend our gradle file only.
30
+
31
+
First we have to import, so we change plugins to the following:
32
+
```
33
+
plugins {
34
+
id 'application'
35
+
id 'java'
36
+
id 'jacoco'
37
+
}
38
+
```
39
+
40
+
When we activates Jacoco plugin it automatically creates a `jacocoTestReport` task in our gradle project.
41
+
We want to ask the gradle to run the code coverage report after every test, so we add
42
+
```
43
+
test {
44
+
finalizedBy jacocoTestReport
45
+
}
46
+
```
47
+
that activates the `jacocoTestReport` right after the `test` task finished.
48
+
Therefore if we run `gradle test` it will create the code coverage as well.
49
+
50
+
If we want to make sure the test results are exists we can say for the gradle if we want to run directly the `jacocoTestReport` by the `gradle jacocoTestReport` command, then please run the `test` before by
51
+
```
52
+
jacocoTestReport {
53
+
dependsOn test
54
+
}
55
+
```
56
+
57
+
So our new shiny *build.gradle* file:
58
+
```
59
+
plugins {
60
+
id 'application'
61
+
id 'java'
62
+
id 'jacoco'
63
+
}
64
+
65
+
repositories {
66
+
mavenCentral()
67
+
}
68
+
69
+
test {
70
+
finalizedBy jacocoTestReport
71
+
}
72
+
jacocoTestReport {
73
+
dependsOn test
74
+
}
75
+
76
+
dependencies {
77
+
implementation 'com.google.guava:guava:31.1-jre'
78
+
}
79
+
80
+
testing {
81
+
suites {
82
+
test {
83
+
useJUnit('4.13.2')
84
+
}
85
+
}
86
+
}
87
+
88
+
application {
89
+
mainClass = 'MultiplyTest.App'
90
+
}
91
+
```
92
+
93
+
By default it will create the report in `build/reports/jacoco/test/html` folder.
94
+
95
+
For more configuration: https://docs.gradle.org/current/userguide/jacoco_plugin.html
96
+
97
+
## If jacoco skipeed
98
+
99
+
Run `gradle clean` to clean the gradle build directory, that helps in many cases.
100
+
101
+
# Extend with function with branches
102
+
103
+
```
104
+
public int max(int aLeft, int aRight) {
105
+
if(aLeft > aRight){
106
+
return aLeft;
107
+
}else{
108
+
return aRight;
109
+
}
110
+
}
111
+
```
112
+
113
+
We can check in the report what lines tested exactly.
114
+
115
+
# How can get this on the server?
116
+
117
+
We have to define to the GitLab we want to save some information from the specific stage by extending with artifacts part the job descriptor.
118
+
119
+
```
120
+
test_with_coverage:
121
+
stage: test
122
+
image: gradle:8.0.2
123
+
script:
124
+
- gradle test
125
+
artifacts:
126
+
paths:
127
+
- build/reports/jacoco/test/html
128
+
expire_in: 1 week
129
+
```
130
+
131
+
More info: https://docs.gitlab.com/ci/jobs/job_artifacts/
132
+
133
+
From this point we can download from the job view directly our code coverage report or publish to somewhere in a next stage.
- Create a milestone titled "I learn how to use GitLab ([your name])".
142
+
- Create a wiki page. Set the title to your name. As content:
143
+
- Add a clickable link to google.
144
+
- Add a code snippet into the page
145
+
- Add link to your milestone
146
+
- Add a link to one of your issue (created in the last session)
147
+
- Copy the source files from this repository (Rectangle classes) and commit to the sandbox project onto a new branch.
148
+
- Write test for the Rectangle classes (Functionality of Rectangle classes, exception as well, but Main class not needed to be tested).
149
+
- Achieve 100% testing coverage of the source code with the tests.
150
+
- Create a Merge request about your branch to the master, put a link to your wiki page and your milestone into the merge request and assign it to me @hudi89.
0 commit comments