Skip to content

Commit 603a092

Browse files
authored
feat(java): 📈 added code coverage check before commit (#119)
* feat(java): 📈 added code coverage check before commit minimum coverage should be 70% before you can commit * docs(java): 📝 updated documentations for the pre-commit checks * docs(website): 📝 updated documentations to add API links * test(java): ✅ disabled firefox tests
1 parent 31137c7 commit 603a092

File tree

30 files changed

+290
-191
lines changed

30 files changed

+290
-191
lines changed

.github/workflows/test-java.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
path: ${{ github.workspace }}/core-java
7676

7777
- name: Start Selenium Grid
78-
run: java -jar core-java/libs/selenium-server-4.1.2.jar standalone > core-java/selenium-grid.log &
78+
run: java -jar core-java/libs/selenium-server-4.3.0.jar standalone > core-java/selenium-grid.log &
7979

8080
- name: All Test execution
8181
if: github.event_name != 'pull_request'

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
yarn lint-staged
55
yarn build:site
6-
mvn install -f core-java/pom.xml -DskipTests
6+
mvn org.jacoco:jacoco-maven-plugin:prepare-agent install -f core-java/pom.xml -Pcoverage-per-test -Dsuite-xml=test-suites/testng-local-husky.xml

README.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -55,70 +55,70 @@
5555

5656
<!-- Table of Contents -->
5757

58-
# :notebook_with_decorative_cover: Table of Contents
59-
60-
- [:notebook_with_decorative_cover: Table of Contents](#notebook_with_decorative_cover-table-of-contents)
61-
- [:star2: About the Project](#star2-about-the-project)
62-
- [:camera: Screenshots](#camera-screenshots)
63-
- [:hammer_and_wrench: Boyka Config file](#hammer_and_wrench-boyka-config-file)
64-
- [:knot: API Sample](#knot-api-sample)
65-
- [:computer: Web Sample](#computer-web-sample)
66-
- [:space_invader: Tech Stack](#space_invader-tech-stack)
67-
- [:house_buildings: Boyka Framework](#house_buildings-boyka-framework)
68-
- [:computer: Main project and Website](#computer-main-project-and-website)
69-
- [:dart: Features](#dart-features)
70-
- [:eyes: Usage](#eyes-usage)
71-
- [:compass: Future Road-map](#compass-future-road-map)
72-
- [:wave: Contributing](#wave-contributing)
73-
- [:scroll: Code of Conduct](#scroll-code-of-conduct)
74-
- [:warning: License](#warning-license)
75-
- [:handshake: Contact](#handshake-contact)
76-
- [:gem: Acknowledgements](#gem-acknowledgements)
58+
# 📔 Table of Contents
59+
60+
- [📔 Table of Contents](#-table-of-contents)
61+
- [🌟 About the Project](#-about-the-project)
62+
- [📷 Screenshots](#-screenshots)
63+
- [🛠️ Boyka Config file](#-boyka-config-file)
64+
- [🪢 API Sample](#-api-sample)
65+
- [💻 Web Sample](#-web-sample)
66+
- [👾 Tech Stack](#-tech-stack)
67+
- [🏘️ Boyka Framework](#-boyka-framework)
68+
- [💻 Main project and Website](#-main-project-and-website)
69+
- [🎯 Features](#-features)
70+
- [👀 Usage](#-usage)
71+
- [🧭 Future Road-map](#-future-road-map)
72+
- [👋 Contributing](#-contributing)
73+
- [📜 Code of Conduct](#-code-of-conduct)
74+
- [⚠️ License](#-license)
75+
- [🤝 Contact](#-contact)
76+
- [💎 Acknowledgements](#-acknowledgements)
7777

7878
<!-- About the Project -->
7979

80-
## :star2: About the Project
80+
## 🌟 About the Project
8181

8282
<!-- Screenshots -->
83-
### :camera: Screenshots
83+
### 📷 Screenshots
8484

85-
#### :hammer_and_wrench: Boyka Config file
85+
#### 🛠️ Boyka Config file
8686

8787
<div>
8888
<img src="assets/config.png" alt="Boyka Config" width="400" height="auto" />
8989
</div>
9090

91-
#### :knot: API Sample
91+
#### 🪢 API Sample
9292

9393
<div>
9494
<img src="assets/api-schemas.png" alt="API Schemas" width="400" height="auto" />
9595
<img src="assets/api.png" alt="API sample" width="400" height="auto" />
9696
</div>
9797

98-
#### :computer: Web Sample
98+
#### 💻 Web Sample
9999

100100
<div>
101101
<img src="assets/page.png" alt="Web Page object" width="400" height="auto" />
102102
<img src="assets/web.png" alt="Web Test" width="400" height="auto" />
103103
</div>
104104

105105
<!-- TechStack -->
106-
### :space_invader: Tech Stack
106+
### 👾 Tech Stack
107107

108-
#### :house_buildings: Boyka Framework
108+
#### 🏘️ Boyka Framework
109109

110110
<div>
111111
<img src="assets/boyka-core-tech-stack.png" alt="Boyka core tech stack" width="400" height="auto" />
112112
</div>
113113

114-
#### :computer: Main project and Website
114+
#### 💻 Main project and Website
115115

116116
<div>
117117
<img src="assets/boyka-main-tech-stack.png" alt="Boyka Main project tech stack" width="400" height="auto" />
118118
</div>
119119

120120
<!-- Features -->
121-
### :dart: Features
121+
### 🎯 Features
122122

123123
- Supports Rest API Automation
124124
- Supports Web Automation
@@ -131,7 +131,7 @@
131131
- Has in-built Assertion methods
132132

133133
<!-- Usage -->
134-
## :eyes: Usage
134+
## 👀 Usage
135135

136136
Use this space to tell a little more about your project and how it can be used. Show additional screenshots, code samples, demos or link to other resources.
137137

@@ -144,12 +144,12 @@ Use this space to tell a little more about your project and how it can be used.
144144
```
145145

146146
<!-- Road-map -->
147-
## :compass: Future Road-map
147+
## 🧭 Future Road-map
148148

149149
See our [Road-map project](https://github.com/orgs/WasiqBhamla/projects/4/views/1) for more details.
150150

151151
<!-- Contributing -->
152-
## :wave: Contributing
152+
## 👋 Contributing
153153

154154
[![Contributors](https://contrib.rocks/image?repo=WasiqBhamla/boyka-framework)](https://github.com/WasiqBhamla/boyka-framework/graphs/contributors)
155155

@@ -158,24 +158,24 @@ Contributions are always welcome!
158158
See [`contributing.md`](./.github/CONTRIBUTING.md) for ways to get started.
159159

160160
<!-- Code of Conduct -->
161-
### :scroll: Code of Conduct
161+
### 📜 Code of Conduct
162162

163163
Please read the [Code of Conduct](./.github/CODE_OF_CONDUCT.md)
164164

165165
<!-- License -->
166-
## :warning: License
166+
## ⚠️ License
167167

168168
Distributed under MIT License. See [LICENSE](LICENSE) for more information.
169169

170170
<!-- Contact -->
171-
## :handshake: Contact
171+
## 🤝 Contact
172172

173173
- Join our [Discord server](https://discord.gg/dUg8K9DAsR) to discuss anything about the framework
174174
- Open a [new Discussion](https://github.com/WasiqBhamla/boyka-framework/discussions/new) on GitHub to ask questions or to discuss ideas
175175
- Contact / Follow me on [Twitter @WasiqBhamla](https://twitter.com/WasiqBhamla)
176176

177177
<!-- Acknowledgments -->
178-
## :gem: Acknowledgements
178+
## 💎 Acknowledgements
179179

180180
Big thanks to the following organizations for their support to the project with their open source licenses:
181181

core-java/pom.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,27 @@
400400
<outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
401401
</configuration>
402402
</execution>
403+
<execution>
404+
<id>jacoco-check</id>
405+
<goals>
406+
<goal>check</goal>
407+
</goals>
408+
<configuration>
409+
<dataFile>${sonar.report}</dataFile>
410+
<rules>
411+
<rule>
412+
<element>PACKAGE</element>
413+
<limits>
414+
<limit>
415+
<counter>LINE</counter>
416+
<value>COVEREDRATIO</value>
417+
<minimum>0.7</minimum>
418+
</limit>
419+
</limits>
420+
</rule>
421+
</rules>
422+
</configuration>
423+
</execution>
403424
</executions>
404425
</plugin>
405426
<plugin>

core-java/src/main/java/com/github/wasiqb/boyka/actions/ElementFinder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ private static <D extends WebDriver> List<WebElement> finds (final D driver, fin
8787
final var wait = getSession ().getWait ();
8888
switch (waitStrategy) {
8989
case CLICKABLE:
90-
wait.until (elementToBeClickable (locator.getLocator ()));
90+
wait.until (elementToBeClickable (locator.getWeb ()));
9191
break;
9292
case VISIBLE:
9393
default:
94-
wait.until (visibilityOfElementLocated (locator.getLocator ()));
94+
wait.until (visibilityOfElementLocated (locator.getWeb ()));
9595
}
9696
return LOGGER.traceExit (
97-
parent != null ? parent.findElements (locator.getLocator ()) : driver.findElements (locator.getLocator ()));
97+
parent != null ? parent.findElements (locator.getWeb ()) : driver.findElements (locator.getWeb ()));
9898
}
9999

100100
private static <D extends WebDriver> List<WebElement> finds (final D driver, final Locator locator,

core-java/src/main/java/com/github/wasiqb/boyka/builders/Locator.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616

1717
package com.github.wasiqb.boyka.builders;
1818

19-
import static com.github.wasiqb.boyka.enums.Message.APP_TYPE_NOT_SUPPORT_DRIVERS;
20-
import static com.github.wasiqb.boyka.sessions.ParallelSession.getSession;
2119
import static org.apache.logging.log4j.LogManager.getLogger;
2220

2321
import java.util.function.Predicate;
2422

25-
import com.github.wasiqb.boyka.exception.FrameworkError;
2623
import lombok.Builder;
2724
import lombok.Getter;
2825
import lombok.ToString;
@@ -42,35 +39,8 @@
4239
public class Locator {
4340
private static final Logger LOGGER = getLogger ();
4441

45-
private By android;
4642
private Predicate<WebElement> filter;
4743
private int index;
48-
private By ios;
4944
private Locator parent;
5045
private By web;
51-
52-
/**
53-
* Returns locator specific to application type.
54-
*
55-
* @return {@link By}
56-
*/
57-
public By getLocator () {
58-
LOGGER.traceEntry ();
59-
final By result;
60-
switch (getSession ().getApplicationType ()) {
61-
case ANDROID:
62-
result = this.android;
63-
break;
64-
case IOS:
65-
result = this.ios;
66-
break;
67-
case WEB:
68-
result = this.web;
69-
break;
70-
case API:
71-
default:
72-
throw new FrameworkError (APP_TYPE_NOT_SUPPORT_DRIVERS.getMessageText ());
73-
}
74-
return LOGGER.traceExit (result);
75-
}
7646
}

core-java/src/main/java/com/github/wasiqb/boyka/config/ui/UISetting.java

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,10 @@
1616

1717
package com.github.wasiqb.boyka.config.ui;
1818

19-
import static com.github.wasiqb.boyka.enums.ApplicationType.ANDROID;
20-
import static com.github.wasiqb.boyka.enums.ApplicationType.IOS;
21-
import static com.github.wasiqb.boyka.enums.Message.INVALID_PLATFORM_FOR_OPERATION;
22-
import static java.text.MessageFormat.format;
23-
import static java.util.Objects.requireNonNull;
2419
import static org.apache.logging.log4j.LogManager.getLogger;
2520

2621
import java.util.Map;
2722

28-
import com.github.wasiqb.boyka.enums.ApplicationType;
29-
import com.github.wasiqb.boyka.exception.FrameworkError;
3023
import lombok.Data;
3124
import org.apache.logging.log4j.Logger;
3225

@@ -38,29 +31,9 @@
3831
public class UISetting {
3932
private static final Logger LOGGER = getLogger ();
4033

41-
private Map<String, MobileSetting> android;
42-
private Map<String, MobileSetting> ios;
43-
private ScreenshotSetting screenshot = new ScreenshotSetting ();
44-
private TimeoutSetting timeout = new TimeoutSetting ();
45-
private Map<String, WebSetting> web;
46-
47-
/**
48-
* Gets the mobile setting.
49-
*
50-
* @param applicationType the {@link ApplicationType}
51-
* @param key the config key for Mobile
52-
*
53-
* @return the {@link MobileSetting}
54-
*/
55-
public MobileSetting getMobileSetting (final ApplicationType applicationType, final String key) {
56-
LOGGER.traceEntry ("ApplicationType: {}, Key: {}", applicationType, key);
57-
if (applicationType == IOS) {
58-
return LOGGER.traceExit (requireNonNull (this.ios.get (key)));
59-
} else if (applicationType == ANDROID) {
60-
return LOGGER.traceExit (requireNonNull (this.android.get (key)));
61-
}
62-
throw new FrameworkError (format (INVALID_PLATFORM_FOR_OPERATION.getMessageText (), applicationType));
63-
}
34+
private ScreenshotSetting screenshot = new ScreenshotSetting ();
35+
private TimeoutSetting timeout = new TimeoutSetting ();
36+
private Map<String, WebSetting> web;
6437

6538
/**
6639
* Gets the web setting.

core-java/src/main/java/com/github/wasiqb/boyka/enums/ApplicationType.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,12 @@
2323
* @since 17-Feb-2022
2424
*/
2525
public enum ApplicationType {
26-
/**
27-
* Android application.
28-
*/
29-
ANDROID,
3026
/**
3127
* API application.
3228
*/
3329
API,
34-
/**
35-
* iOS application.
36-
*/
37-
IOS,
3830
/**
3931
* Web application.
4032
*/
4133
WEB
42-
}
34+
}

core-java/src/main/java/com/github/wasiqb/boyka/enums/Message.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
@Getter
2828
public enum Message {
2929
/**
30-
* Driver does not support API application type
30+
* Driver only supports Web application type
3131
*/
32-
APP_TYPE_NOT_SUPPORT_DRIVERS ("API application type does not support drivers..."),
32+
APP_TYPE_NOT_SUPPORTED ("Application type [{0}] is not yet supported..."),
3333
/**
3434
* Basic auth password is empty.
3535
*/
@@ -122,6 +122,10 @@ public enum Message {
122122
* Schema validation assert failure
123123
*/
124124
RESPONSE_SCHEMA_NOT_MATCHING ("Schema validation assert failure..."),
125+
/**
126+
* Test Error.
127+
*/
128+
TEST_ERROR ("Test error..."),
125129
/**
126130
* User name required for cloud execution
127131
*/

0 commit comments

Comments
 (0)