Skip to content

Commit

Permalink
Improve java doc (#6)
Browse files Browse the repository at this point in the history
* Improve java doc

* Fix
  • Loading branch information
rogervinas authored Nov 16, 2023
1 parent 94360a1 commit 3da7e1f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea
.DS_Store
39 changes: 30 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,23 @@
[![CI](https://github.com/rogervinas/tests-everywhere/actions/workflows/java.yml/badge.svg)](https://github.com/rogervinas/tests-everywhere/actions/workflows/java.yml)
![Java](https://img.shields.io/badge/Java-21-blue?labelColor=black)

Using:
* [JUnit5](https://junit.org/junit5/)
* [Mockito](https://site.mockito.org/)
* [AssertJ](https://assertj.github.io/doc/)
Java testing with [JUnit5](https://junit.org/junit5/), [Mockito](https://site.mockito.org/) and [AssertJ](https://assertj.github.io/doc/)

### Pre-requisites
* Install [Java](https://openjdk.org/) and [Gradle](https://gradle.org/) manually or ...
* Install [SdkMan](https://sdkman.io/) and ...
* Install **Java** using `sdk install java 21-tem` (use `sdk list java` to see all versions)
* Install **Gradle** using `sdk install grade 8.4` (use `sdk list gradle` to see all versions)

### Create project from scratch
* Create project using `gradle init --type java-application --test-framework junit-jupiter`
* Add required dependencies in `build.gradle.kts`:
* `testImplementation("org.mockito:mockito-core:x.x.x")`
* `testImplementation("org.assertj:assertj-core:x.x.x")`

### Run this project
* Test with `./gradlew test`
* Run with `./gradlew run`

## Kotlin

Expand All @@ -29,15 +42,23 @@ Using:

JavaScript testing with [Jest](https://jestjs.io/)

Pre-requisites:
* Install [Node Version Manager](https://github.com/nvm-sh/nvm)
* Install [Node.js](https://nodejs.org/en/) using `nvm use v18` or `nvm use stable`
### Pre-requisites
* Install [Node.js](https://nodejs.org/en/) manually or ...
* Install [Node Version Manager](https://github.com/nvm-sh/nvm) and ...
* Install **Node.js** executing `nvm use v18` or `nvm use stable`

Create project from scratch:
### Create project from scratch
* Create project using `npm init`
* Install [Jest](https://jestjs.io/) using `npm install --save-dev jest`
* Configure scripts in `package.json`:
```json
"scripts": {
"start": "node index.js",
"test": "jest"
}
```

Run this project:
### Run this project
* Install dependencies running `npm install`
* Test with `npm test`
* Run with `npm start`
5 changes: 5 additions & 0 deletions java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent.*

plugins {
java
application
}

repositories {
Expand Down Expand Up @@ -32,3 +33,7 @@ tasks.named<Test>("test") {
showStackTraces = true
}
}

application {
mainClass.set("org.hello.Main")
}
6 changes: 4 additions & 2 deletions java/src/main/java/org/hello/HelloConsole.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.hello;

public interface HelloConsole {
void print(String text);
public class HelloConsole {
public void print(String text) {
System.out.println(text);
}
}
10 changes: 10 additions & 0 deletions java/src/main/java/org/hello/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.hello;

public class Main {

public static void main(String[] args) {
var message = new HelloMessage();
var console = new HelloConsole();
new HelloApp(message, console).printHello();
}
}

0 comments on commit 3da7e1f

Please sign in to comment.