Skip to content
Jan Hermann edited this page Oct 19, 2026 · 3 revisions

πŸ§ͺ

Test suite for checking library functions.

The project includes both a robust JUnit test suite for Java classes and equivalent unit tests for JavaScript files located in the test/ directory, ensuring correctness across date conversions, Easter calculation algorithms, Czech name days lookups, and leap year validation logic.

πŸ“‹ Test Classes

β˜• Java Tests (JUnit 4)

  • DateTest.java: Located in test/timely/dates/DateTest.java, this JUnit test class contains test cases for the Java class Date.java.
  • CalculatorTest.java: Located in test/timely/easter/CalculatorTest.java, this JUnit test class contains test cases for the Java class Calculator.java.
  • CzechFinderTest.java: Located in test/timely/namedays/CzechFinderTest.java, this JUnit test class contains test cases for the Java class CzechFinder.java.
  • HelperTest.java: Located in test/timely/years/HelperTest.java, this JUnit test class contains test cases for the Java class Helper.java.

🌐 JavaScript Tests (Node.js)

The tests are ES modules and use the Timely namespace (import * as Timely from ".../src/timely/index.js").

  • DateTest.js: Located in test/timely/dates/DateTest.js, tests day of week utilities (DateFormatter.js, Week.js).
  • CalculatorTest.js: Located in test/timely/easter/CalculatorTest.js, tests Oudin's Easter algorithm (EasterCalculator.js).
  • CzechFinderTest.js: Located in test/timely/namedays/CzechFinderTest.js, tests Czech name day lookups (czech.js, CzechNameDayFinder.js).
  • HelperTest.js: Located in test/timely/years/HelperTest.js, tests leap year calculations (YearHelper.js).

πŸš€ Running Tests

β˜• Running Java Tests

The Java test suite can be executed using independent scripts, any Java IDE, or command-line environment configured with JUnit 4:

  1. Using Independent Scripts:

    • On Windows (PowerShell):

    .\java-tests.ps1

    -	On Unix/Linux/macOS (Bash):
      ```bash
    ./java-tests.sh
    
  2. Integrated Development Environment (IDE):

    • Open the project in an IDE such as IntelliJ IDEA or Eclipse.
    • Ensure src/ is configured as the source directory and test/ as the test source directory.
    • Ensure JUnit 4 (and required dependencies) is added to the project classpath/module dependencies.
    • Right-click on the test/ directory or individual test classes (e.g., DateTest.java, CalculatorTest.java, CzechFinderTest.java, HelperTest.java) and select Run.
  3. Command Line:

    • Compile both source and test files together with JUnit 4 and Hamcrest libraries on the classpath:

    javac -cp "lib/*;src;test" test/timely/dates/DateTest.java test/timely/easter/CalculatorTest.java test/timely/namedays/CzechFinderTest.java test/timely/years/HelperTest.java

    -	Execute the compiled test classes using `org.junit.runner.JUnitCore`:
      ```bash
    java -cp "lib/*;src;test" org.junit.runner.JUnitCore timely.dates.DateTest timely.easter.CalculatorTest timely.namedays.CzechFinderTest timely.years.HelperTest
    
    *(Note: Adjust path separators (e.g. `:` instead of `;` on Linux/macOS) and ensure JUnit 4 (`junit.jar`) and Hamcrest (`hamcrest-core.jar`) are placed in the `lib/` directory or specified in your classpath).*
    

🌐 Running JavaScript Tests

JavaScript test dependencies can be installed using npm:

npm install

The JavaScript test suite can then be executed using npm, Composer, or directly via Node.js from the project root directory:

  1. Using npm:

npm test


2.	**Using Composer**:
 ```bash
composer test
  1. Directly using Node.js:

node test/timely/years/HelperTest.js node test/timely/easter/CalculatorTest.js node test/timely/namedays/CzechFinderTest.js node test/timely/dates/DateTest.js

Clone this wiki locally