Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yegor256/jping
JUnit5 execution condition that makes sure a connection to a public Internet exists
https://github.com/yegor256/jping
junit junit5 junit5-extension junit5-tests testing unit-testing unit-testing-framework
Last synced: 7 days ago
JSON representation
JUnit5 execution condition that makes sure a connection to a public Internet exists
- Host: GitHub
- URL: https://github.com/yegor256/jping
- Owner: yegor256
- License: mit
- Created: 2023-12-22T13:58:27.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-08-14T10:36:31.000Z (3 months ago)
- Last Synced: 2024-08-14T12:12:01.821Z (3 months ago)
- Topics: junit, junit5, junit5-extension, junit5-tests, testing, unit-testing, unit-testing-framework
- Language: Java
- Homepage:
- Size: 42 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)
[![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/jping)](http://www.rultor.com/p/yegor256/jping)
[![We recommend IntelliJ IDEA](https://www.elegantobjects.org/intellij-idea.svg)](https://www.jetbrains.com/idea/)[![mvn](https://github.com/yegor256/jping/actions/workflows/mvn.yml/badge.svg)](https://github.com/yegor256/jping/actions/workflows/mvn.yml)
[![PDD status](http://www.0pdd.com/svg?name=yegor256/jping)](http://www.0pdd.com/p?name=yegor256/jping)
[![Maven Central](https://img.shields.io/maven-central/v/com.yegor256/jping.svg)](https://maven-badges.herokuapp.com/maven-central/com.yegor256/jping)
[![Javadoc](http://www.javadoc.io/badge/com.yegor256/jping.svg)](http://www.javadoc.io/doc/com.yegor256/jping)
[![codecov](https://codecov.io/gh/yegor256/jping/branch/master/graph/badge.svg)](https://codecov.io/gh/yegor256/jping)
[![Hits-of-Code](https://hitsofcode.com/github/yegor256/jping)](https://hitsofcode.com/view/github/yegor256/jping)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/jping/blob/master/LICENSE.txt)JUnit5 execution condition that checks whether a connection to public Internet is available.
First, you add this to your `pom.xml`:
```xml
com.yegor256
jping
0.0.3
test```
Then, you use it like this:
```java
import com.yegor256.WeAreOnline;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;@ExtendWith(WeAreOnline.class)
final class MyTest {
@Test
void canDownloadViaHttp() throws Exception {
new URL("https://www.google.com").openStream();
}
}
```Or if need to override default settings:
```java
import com.yegor256.OnlineMeans;
import com.yegor256.WeAreOnline;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;@ExtendWith(WeAreOnline.class)
final class MyTest {
@Test
@OnlineMeans(url = "https://www.amazon.com", connectTimeout = 500, readTimeout = 1500)
void canDownloadViaHttp() throws Exception {
new URL("https://www.amazon.com").openStream();
}
}
```We don't want this unit test to be executed when no Internet connection
is available. The `WeAreOnline` execution condition will prevent JUnit5 from
executing the test when you are offline.## How to Contribute
Fork repository, make changes, send us a [pull request](https://www.yegor256.com/2014/04/15/github-guidelines.html).
We will review your changes and apply them to the `master` branch shortly,
provided they don't violate our quality standards. To avoid frustration,
before sending us your pull request please run full Maven build:```bash
$ mvn clean install -Pqulice
```You will need Maven 3.3+ and Java 8+.