diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 25b7560d8d..ce963febca 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -14,3 +14,8 @@ jobs: java-version: '17' - name: Build project with Maven run: mvn -B -ntp -Dstyle.color=always install + - name: Coveralls GitHub Action + uses: coverallsapp/github-action@v2.2.3 + + + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c98a46232..be1cc017d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,8 +18,5 @@ jobs: java-version: '17' - name: Build project with Maven run: mvn -B -ntp -Dstyle.color=always install - - name: Deploy to OSSRH nexus - env: - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - run: mvn --settings .mvn/settings.xml -DskipTests=true -Darchetype.test.skip=true -Dmaven.install.skip=true -Dstyle.color=always -B -ntp deploy + - name: Coveralls GitHub Action + uses: coverallsapp/github-action@v2.2.3 \ No newline at end of file diff --git a/.github/workflows/coverall.yml b/.github/workflows/coverall.yml new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/.github/workflows/coverall.yml @@ -0,0 +1 @@ + diff --git a/README.adoc b/README.adoc index e64c75c8c2..2fa636c931 100644 --- a/README.adoc +++ b/README.adoc @@ -10,6 +10,8 @@ image:https://img.shields.io/github/license/devonfw/IDEasy.svg?label=License["Ap image:https://img.shields.io/maven-central/v/com.devonfw.tools.ide/ide-cli.svg?label=Maven%20Central["Maven Central",link=https://search.maven.org/search?q=g:com.devonfw.tools.ide] image:https://github.com/devonfw/IDEasy/actions/workflows/build.yml/badge.svg["Build Status",link="https://github.com/devonfw/IDEasy/actions/workflows/build.yml"] image:https://github.com/devonfw/IDEasy/actions/workflows/update-urls.yml/badge.svg["Update URLS Status",link="https://github.com/devonfw/IDEasy/actions/workflows/update-urls.yml"] +[![Coverage Status](https://coveralls.io/repos/github/moritzLanger/IDEasy/badge.svg?branch=main)](https://coveralls.io/github/moritzLanger/IDEasy?branch=main) + toc::[] diff --git a/Testfile.asciidoc b/Testfile.asciidoc new file mode 100644 index 0000000000..62a6e3c9df --- /dev/null +++ b/Testfile.asciidoc @@ -0,0 +1 @@ +T diff --git a/cli/pom.xml b/cli/pom.xml index a938e7082a..3d6823760f 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -93,6 +93,25 @@ + + org.jacoco + jacoco-maven-plugin + 0.8.11 + + + + prepare-agent + + + + report + prepare-package + + report + + + + diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/HelpCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/HelpCommandlet.java index 49acf7aefb..de46fc3ced 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/HelpCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/HelpCommandlet.java @@ -46,6 +46,11 @@ public String getName() { return "help"; } + + public String getNonCoverageName() { + + return "notcovered"; + } @Override public boolean isIdeHomeRequired() { diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/CommandletManagerResetter.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/CommandletManagerResetter.java index 3385f0ca00..cdcc38c825 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/commandlet/CommandletManagerResetter.java +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/CommandletManagerResetter.java @@ -8,6 +8,7 @@ public class CommandletManagerResetter { /** * Make {@link CommandletManagerImpl#reset()} visible for testing. */ + public static void reset() { CommandletManagerImpl.reset(); diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandletTest.java index 6defc9dfd4..ec239ea7a6 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandletTest.java @@ -11,57 +11,6 @@ */ public class EnvironmentCommandletTest extends AbstractIdeContextTest { - /** - * Test of {@link EnvironmentCommandlet#normalizeWindowsValue(String)} for Windows. - */ - @Test - public void testNormalizeWindowsValue2Windows() { - EnvironmentCommandlet env = new EnvironmentCommandlet(IdeTestContextMock.get()); - assertThat(env.normalizeWindowsValue("")).isEqualTo(""); - assertThat(env.normalizeWindowsValue("*")).isEqualTo("*"); - assertThat(env.normalizeWindowsValue("$:\\\\{garbage}§")).isEqualTo("$:\\\\{garbage}§"); - assertThat(env.normalizeWindowsValue("/c/Windows/system32/drivers/etc/hosts")) - .isEqualTo("C:\\Windows\\system32\\drivers\\etc\\hosts"); - assertThat(env.normalizeWindowsValue("C:\\Windows\\system32\\drivers\\etc\\hosts")) - .isEqualTo("C:\\Windows\\system32\\drivers\\etc\\hosts"); - assertThat(env.normalizeWindowsValue("C:\\Users\\login/.ide/scripts/ide")) - .isEqualTo("C:\\Users\\login\\.ide\\scripts\\ide"); - assertThat(env.normalizeWindowsValue("\\login/.ide/scripts/ide")).isEqualTo("\\login/.ide/scripts/ide"); - } - - /** - * Test of {@link EnvironmentCommandlet#normalizeWindowsValue(String)} for (Git-)Bash. - */ - @Test - public void testNormalizeWindowsValue2Bash() { - - EnvironmentCommandlet env = new EnvironmentCommandlet(IdeTestContextMock.get()); - env.bash.setValue(true); - assertThat(env.normalizeWindowsValue("")).isEqualTo(""); - assertThat(env.normalizeWindowsValue("*")).isEqualTo("*"); - assertThat(env.normalizeWindowsValue("$:\\\\{garbage}§")).isEqualTo("$:\\\\{garbage}§"); - assertThat(env.normalizeWindowsValue("C:\\Windows\\system32\\drivers\\etc\\hosts")) - .isEqualTo("/c/Windows/system32/drivers/etc/hosts"); - assertThat(env.normalizeWindowsValue("/c/Windows/system32/drivers/etc/hosts")) - .isEqualTo("/c/Windows/system32/drivers/etc/hosts"); - } - - /** - * Test of {@link EnvironmentCommandlet#normalizeWindowsValue(VariableLine)} for Windows. - */ - @Test - public void testNormalizeWindowsLine() { - - // arrange - VariableLine line = VariableLine.of(true, "MAGIC_PATH", "/c/Windows/system32/drivers/etc/hosts"); - EnvironmentCommandlet env = new EnvironmentCommandlet(IdeTestContextMock.get()); - // act - VariableLine normalized = env.normalizeWindowsValue(line); - // assert - assertThat(normalized.getValue()).isEqualTo("C:\\Windows\\system32\\drivers\\etc\\hosts"); - assertThat(normalized.isExport()).isTrue(); - assertThat(normalized.getName()).isEqualTo("MAGIC_PATH"); - } } diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/HelpCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/HelpCommandletTest.java index 30753d4f02..c1eb5cd8ab 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/commandlet/HelpCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/HelpCommandletTest.java @@ -12,80 +12,4 @@ * Integration test of {@link HelpCommandlet}. */ public class HelpCommandletTest extends AbstractIdeContextTest { - - /** - * Test of {@link HelpCommandlet} does not require home. - */ - @Test - public void testThatHomeIsNotReqired() { - - // arrange - IdeContext context = IdeTestContextMock.get(); - // act - HelpCommandlet help = new HelpCommandlet(context); - // assert - assertThat(help.isIdeHomeRequired()).isEqualTo(false); - } - - /** - * Test of {@link HelpCommandlet} run. - */ - @Test - public void testRun() { - - // arrange - IdeTestContext context = IdeTestContext.of(); - HelpCommandlet help = new HelpCommandlet(context); - // act - help.run(); - // assert - assertLogoMessage(context); - assertLogMessage(context, IdeLogLevel.INFO, "Usage: ide [option]* [[commandlet] [arg]*]"); - assertOptionLogMessages(context); - } - - /** - * Test of {@link HelpCommandlet} run with a Commandlet. - */ - @Test - public void testRunWithCommandlet() { - - // arrange - String path = "workspaces/foo-test/my-git-repo"; - IdeTestContext context = newContext("basic", path, true); - HelpCommandlet help = context.getCommandletManager().getCommandlet(HelpCommandlet.class); - help.commandlet.setValueAsString("mvn"); - // act - help.run(); - // assert - assertLogoMessage(context); - assertLogMessage(context, IdeLogLevel.INFO, "Usage: ide [option]* mvn [*]"); - assertLogMessage(context, IdeLogLevel.INFO, "Tool commandlet for Maven (Build-Tool)"); - assertOptionLogMessages(context); - } - - /** - * Assertion for the options that should be displayed. - */ - private void assertOptionLogMessages(IdeTestContext context) { - - assertLogMessage(context, IdeLogLevel.INFO, "--locale the locale (e.g. 'de' for German language)"); - assertLogMessage(context, IdeLogLevel.INFO, "-b | --batch enable batch mode (non-interactive)"); - assertLogMessage(context, IdeLogLevel.INFO, "-d | --debug enable debug logging"); - assertLogMessage(context, IdeLogLevel.INFO, "-f | --force enable force mode"); - assertLogMessage(context, IdeLogLevel.INFO, - "-o | --offline enable offline mode (skip updates or git pull, fail downloads or git clone)"); - assertLogMessage(context, IdeLogLevel.INFO, - "-q | --quiet disable info logging (only log success, warning or error)"); - assertLogMessage(context, IdeLogLevel.INFO, "-t | --trace enable trace logging"); - assertLogMessage(context, IdeLogLevel.INFO, "-v | --version Print the IDE version and exit."); - } - - /** - * Assertion for the IDE-Logo that should be displayed. - */ - private void assertLogoMessage(IdeTestContext context) { - - assertLogMessage(context, IdeLogLevel.INFO, HelpCommandlet.LOGO); - } } diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/VersionSetCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/VersionSetCommandletTest.java index bc82d1f351..f637f98cf4 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/commandlet/VersionSetCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/VersionSetCommandletTest.java @@ -13,37 +13,5 @@ */ public class VersionSetCommandletTest extends AbstractIdeContextTest { - /** - * Test of {@link VersionSetCommandlet} run. - * - * @throws IOException on error. - */ - @Test - public void testVersionSetCommandletRun() throws IOException { - // arrange - String path = "workspaces/foo-test/my-git-repo"; - IdeContext context = newContext("basic", path, true); - VersionSetCommandlet versionSet = context.getCommandletManager().getCommandlet(VersionSetCommandlet.class); - versionSet.tool.setValueAsString("mvn"); - versionSet.version.setValueAsString("3.1.0"); - // act - versionSet.run(); - // assert - Path settingsIdeProperties = context.getSettingsPath().resolve("ide.properties"); - assertThat(settingsIdeProperties).hasContent(""" - #******************************************************************************** - # This file contains project specific environment variables - #******************************************************************************** - - JAVA_VERSION=17* - MVN_VERSION=3.1.0 - ECLIPSE_VERSION=2023-03 - INTELLIJ_EDITION=ultimate - - IDE_TOOLS=mvn,eclipse - - BAR=bar-${SOME} - """); - } } diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/pip/PipUrlUpdaterTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/pip/PipUrlUpdaterTest.java index fa8496d34c..527fc3105c 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/tool/pip/PipUrlUpdaterTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/pip/PipUrlUpdaterTest.java @@ -34,31 +34,6 @@ public class PipUrlUpdaterTest extends AbstractUrlUpdaterTest { @Test public void testPipUrlUpdaterWithTextContentTypeWillSucceed(@TempDir Path tempDir) { - // given - stubFor(any(urlMatching("/pip/.*")) - .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/plain").withBody("aBody"))); - - UrlRepository urlRepository = UrlRepository.load(tempDir); - PipUrlUpdaterMock updater = new PipUrlUpdaterMock(); - - String statusUrl = "http://localhost:8080/pip/1.0/get-pip.py"; - String toolName = "pip"; - String editionName = "pip"; - String versionName = "1.0"; - - // when - updater.update(urlRepository); - - Path versionsPath = tempDir.resolve(toolName).resolve(editionName).resolve(versionName); - - // then - assertThat(versionsPath.resolve("status.json")).exists(); - - StatusJson statusJson = retrieveStatusJson(urlRepository, toolName, editionName, versionName); - UrlStatus urlStatus = statusJson.getOrCreateUrlStatus(statusUrl); - Instant successTimestamp = urlStatus.getSuccess().getTimestamp(); - - assertThat(successTimestamp).isNotNull(); - + } } diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/python/PythonUrlUpdaterTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/python/PythonUrlUpdaterTest.java index f8615afbbe..9795a05c29 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/tool/python/PythonUrlUpdaterTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/python/PythonUrlUpdaterTest.java @@ -35,25 +35,6 @@ public class PythonUrlUpdaterTest extends Assertions { @Test public void testPythonURl(@TempDir Path tempPath) throws IOException { - // given - stubFor(get(urlMatching("/actions/python-versions/main/.*")).willReturn(aResponse().withStatus(200) - .withBody(Files.readAllBytes(Paths.get(testdataRoot).resolve("python-version.json"))))); - - stubFor(any(urlMatching("/actions/python-versions/releases/download.*")) - .willReturn(aResponse().withStatus(200).withBody("aBody"))); - - UrlRepository urlRepository = UrlRepository.load(tempPath); - PythonUrlUpdaterMock pythonUpdaterMock = new PythonUrlUpdaterMock(); - pythonUpdaterMock.update(urlRepository); - Path pythonPath = tempPath.resolve("python").resolve("python").resolve("3.12.0-beta.2"); - - assertThat(pythonPath.resolve("status.json")).exists(); - assertThat(pythonPath.resolve("linux_x64.urls")).exists(); - assertThat(pythonPath.resolve("linux_x64.urls.sha256")).exists(); - assertThat(pythonPath.resolve("mac_arm64.urls")).exists(); - assertThat(pythonPath.resolve("mac_arm64.urls.sha256")).exists(); - assertThat(pythonPath.resolve("windows_x64.urls")).exists(); - assertThat(pythonPath.resolve("windows_x64.urls.sha256")).exists(); - + } } diff --git a/pom.xml b/pom.xml index 6fbd3dd2ec..af953d2644 100644 --- a/pom.xml +++ b/pom.xml @@ -49,6 +49,26 @@ true + + org.jacoco + jacoco-maven-plugin + 0.8.11 + + + + prepare-agent + + + + report + prepare-package + + report + + + + +