Skip to content

Commit

Permalink
v0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels authored Jun 2, 2024
2 parents 120296d + 287b01c commit c00951c
Show file tree
Hide file tree
Showing 128 changed files with 9,349 additions and 21,227 deletions.
94 changes: 93 additions & 1 deletion .github/workflows/Pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,86 @@ 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

Cpp-GoogleTest:
runs-on: ubuntu-latest
steps:
- name: ⏬ Checkout repository
uses: actions/checkout@v4
- name: ⏬ Checkout 'google/googletest' repository
uses: actions/checkout@v4
with:
repository: google/googletest
path: examples/Cpp/GoogleTest/lib/googletest
- name: 🔧 Install dependencies
run: sudo apt-get install -y --no-install-recommends ninja-build
- name: 🛠 Run CMake
run: |
cd examples/Cpp/GoogleTest
cmake -B build -G Ninja
cmake --build build
- name: ✅ Run unit tests (directly)
run: |
cd examples/Cpp/GoogleTest
./build/unit_tests --gtest_output=xml:gtest.xml
- name: ✅ Run unit tests (by ctest)
run: |
cd examples/Cpp/GoogleTest
ctest --test-dir build/ --output-junit ../ctest.xml
- name: List generated XML reports
run: |
ls -lAh examples/Cpp/GoogleTest/*.xml
- name: 📤 Upload JUnit XML files as artifact
uses: actions/upload-artifact@v4
with:
name: Cpp-GoogleTest
path: examples/Cpp/GoogleTest/*.xml

Python-pytest:
runs-on: ubuntu-latest
steps:
- name: ⏬ Checkout repository
uses: actions/checkout@v4
- name: 🐍 Setup Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: 🔧 Install pytest and other dependencies
run: python -m pip install --disable-pip-version-check -U pytest
- name: ✅ Run pytest
run: |
cd examples/Python/pytest
python3 -m pytest -rAP --color=yes --junitxml=TestReportSummary.xml .
- name: List generated XML reports
run: ls -lAh examples/Python/pytest/*.xml
- name: 📤 Upload JUnit XML files as artifact
uses: actions/upload-artifact@v4
with:
name: Python-pytest
path: examples/Python/pytest/*.xml

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

ApplicationTest:
needs:
- Package
- Java-Ant-JUnit4
- Cpp-GoogleTest
- Python-pytest
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 All @@ -70,11 +161,12 @@ jobs:
codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }}

PublishTestResults:
uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@r1
uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@dev
needs:
- UnitTestingParams
- UnitTesting
with:
additional_merge_args: '--pytest "pytest.tests.unit"'
merged_junit_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}

IntermediateCleanUp:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ coverage.xml
# pytest
/report/unit

# generated data from tests
/tests/data/JUnit/.gitignore
/tests/output/

# setuptools
/build/**/*.*
/dist/**/*.*
Expand Down
2 changes: 1 addition & 1 deletion dist/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
wheel ~= 0.43
twine ~= 5.0
twine ~= 5.1
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pyTooling ~= 6.1
colorama >= 0.4.6
ruamel.yaml ~= 0.18.6
setuptools ~= 69.5
setuptools ~= 70.0

# Enforce latest version on ReadTheDocs
sphinx ~= 7.3
Expand Down
35 changes: 35 additions & 0 deletions examples/Cpp/GoogleTest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.20)

# Project configuration
set(PROJECT_NAME Unittesting)
project(${PROJECT_NAME})
# * PROJECT_SOURCE_DIR - Top level source directory for the project
# * PROJECT_BINARY_DIR - Full path to build directory for project

# Compiler flags
set(CMAKE_CXX_FLAGS "-g -Wall")
set(CMAKE_CXX_STANDARD 20)

file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/src/*.[ch]pp)

add_library(app STATIC ${SRC_FILES})
target_include_directories(app PUBLIC ${PROJECT_SOURCE_DIR}/src)

# GoogleTest
add_subdirectory(./lib/googletest)

########################################
# Test files
########################################
file(GLOB TEST_SRC_FILES ${PROJECT_SOURCE_DIR}/test/*.[ch]pp)

########################################
# Unit Tests
########################################
add_executable(unit_tests ${TEST_SRC_FILES})
target_link_libraries(unit_tests app gtest_main)


enable_testing()
include(GoogleTest)
gtest_discover_tests(unit_tests)
13 changes: 13 additions & 0 deletions examples/Cpp/GoogleTest/src/Counter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "Counter.hpp"

int Counter::Value() {
return _value;
}

int Counter::Increment() {
return _value++;
}

int Counter::Decrement() {
return _value--;
}
16 changes: 16 additions & 0 deletions examples/Cpp/GoogleTest/src/Counter.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef COUNTER_H_
#define COUNTER_H_

class Counter {
private:
int _value;

public:
Counter(int value = 0) : _value { value } {}

int Value();
int Increment();
int Decrement();
};

#endif // COUNTER_H_
26 changes: 26 additions & 0 deletions examples/Cpp/GoogleTest/test/Counter.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "Counter.hpp"

#include "gtest/gtest.h"

namespace {

TEST(Counter, Init) {
Counter c0 { 0 };
Counter c1 { 1 };
EXPECT_EQ(0, c0.Value());
EXPECT_EQ(1, c1.Value());
}

TEST(Counter, Increment) {
Counter c { 0 };
EXPECT_EQ(0, c.Increment());
EXPECT_EQ(1, c.Value());
}

TEST(Counter, Decrement) {
Counter c { 1 };
EXPECT_EQ(1, c.Decrement());
EXPECT_EQ(0, c.Value());
}

} // namespace
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());
}

}
42 changes: 42 additions & 0 deletions examples/Python/pytest/TestModuleA.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from unittest import TestCase


class A:
_value: int

def __init__(self, value: int = 0):
self._value = value

@property
def Value(self) -> int:
return self._value

@Value.setter
def Value(self, value: int):
self._value = value


class Instantiation(TestCase):
def test_NoParameter(self):
a = A()

self.assertEqual(0, a.Value)

def test_Parameter(self):
a = A(5)

self.assertEqual(5, a.Value)


class Properties(TestCase):
def test_Getter(self):
a = A(10)

self.assertEqual(10, a.Value)

def test_Setter(self):
a = A(15)
self.assertEqual(15, a.Value)

a.Value = 20
self.assertEqual(20, a.Value)
Loading

0 comments on commit c00951c

Please sign in to comment.