Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java #33

Merged
merged 2 commits into from
May 13, 2024
Merged

Java #33

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/Pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,29 @@ on:
- cron: '0 22 * * 5'

jobs:
Java-Ant-JUnit4:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 11 for x64
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
architecture: x64
- name: Run the Ant 'junit' target
run: |
cd examples/Java/JUnit
ant -noinput -buildfile build-github.xml junit
- name: List generated XML reports
run: ls -lAh examples/Java/JUnit/build/*.xml
- name: Upload JUnit XML files as artifact
uses: actions/upload-artifact@v4
with:
name: Java-Ant-JUnit4
path: examples/Java/JUnit/build/*.xml

UnitTestingParams:
uses: pyTooling/Actions/.github/workflows/Parameters.yml@r1
with:
Expand Down Expand Up @@ -56,6 +79,15 @@ jobs:
python_version: ${{ needs.UnitTestingParams.outputs.python_version }}
artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }}

ApplicationTest:
needs:
- Package
- Java-Ant-JUnit4
runs-on: ubuntu-latest
steps:
- name: Download JUnit XML files
uses: actions/download-artifact@v4

PublishCoverageResults:
uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@r1
needs:
Expand Down
46 changes: 46 additions & 0 deletions examples/Java/JUnit/build-github.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<project name="MyProject" default="junit" basedir=".">
<description>
simple example build file
</description>

<property name="src" location="src" />
<property name="test" location="test" />
<property name="build" location="build" />

<target name="init">
<tstamp />
<mkdir dir="${build}" />
</target>

<target name="compile" depends="init" description="compile the source">
<javac destdir="${build}" includeantruntime="false">
<src path="${src}" />
<src path="${test}" />
<classpath>
<pathelement location="/usr/share/gradle-8.7/lib/junit-4.13.2.jar"/>
</classpath>
</javac>
</target>

<target name="junit" depends="compile">
<junit haltonerror="true" printsummary="true">
<classpath>
<pathelement location="/usr/share/gradle-8.7/lib/junit-4.13.2.jar"/>
<pathelement location="/usr/share/gradle-8.7/lib/hamcrest-core-1.3.jar"/>
<pathelement location="${build}"/>
</classpath>
<formatter type="xml"/>
<batchtest fork="false" todir="${build}">
<fileset dir="${test}">
<include name="**/*Test.java"/>
<include name="**/AllTests.java"/>
</fileset>
</batchtest>
</junit>
</target>

<target name="clean" description="clean up">
<delete dir="${build}" />
<delete dir="${dist}" />
</target>
</project>
7 changes: 7 additions & 0 deletions examples/Java/JUnit/src/my/pack/MyClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package my.pack;

public class MyClass {
boolean returnTrue() {
return false;
}
}
7 changes: 7 additions & 0 deletions examples/Java/JUnit/src/my/pack/OtherClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package my.pack;

public class OtherClass {
int returnThree() {
return 3;
}
}
11 changes: 11 additions & 0 deletions examples/Java/JUnit/test/my/AllTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package my;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

@RunWith(Suite.class)
@SuiteClasses({ my.pack.AllTests.class })
public class AllTests {

}
11 changes: 11 additions & 0 deletions examples/Java/JUnit/test/my/pack/AllTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package my.pack;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

@RunWith(Suite.class)
@SuiteClasses({ MyClassTest.class, OtherClassTest.class })
public class AllTests {

}
14 changes: 14 additions & 0 deletions examples/Java/JUnit/test/my/pack/MyClassTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package my.pack;

import static org.junit.Assert.*;

import org.junit.Test;

public class MyClassTest {

@Test
public void testReturnTrue() {
assertTrue(new MyClass().returnTrue());
}

}
14 changes: 14 additions & 0 deletions examples/Java/JUnit/test/my/pack/OtherClassTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package my.pack;

import static org.junit.Assert.*;

import org.junit.Test;

public class OtherClassTest {

@Test
public void testReturnThree() {
assertEquals(3, new OtherClass().returnThree());
}

}
Loading