Repository navigation
Tests
π§ͺ
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.
-
DateTest.java: Located intest/timely/dates/DateTest.java, this JUnit test class contains test cases for the Java classDate.java. -
CalculatorTest.java: Located intest/timely/easter/CalculatorTest.java, this JUnit test class contains test cases for the Java classCalculator.java. -
CzechFinderTest.java: Located intest/timely/namedays/CzechFinderTest.java, this JUnit test class contains test cases for the Java classCzechFinder.java. -
HelperTest.java: Located intest/timely/years/HelperTest.java, this JUnit test class contains test cases for the Java classHelper.java.
The tests are ES modules and use the Timely namespace (import * as Timely from ".../src/timely/index.js").
-
DateTest.js: Located intest/timely/dates/DateTest.js, tests day of week utilities (DateFormatter.js,Week.js). -
CalculatorTest.js: Located intest/timely/easter/CalculatorTest.js, tests Oudin's Easter algorithm (EasterCalculator.js). -
CzechFinderTest.js: Located intest/timely/namedays/CzechFinderTest.js, tests Czech name day lookups (czech.js,CzechNameDayFinder.js). -
HelperTest.js: Located intest/timely/years/HelperTest.js, tests leap year calculations (YearHelper.js).
The Java test suite can be executed using independent scripts, any Java IDE, or command-line environment configured with JUnit 4:
-
Using Independent Scripts:
- On Windows (PowerShell):
.\java-tests.ps1
- On Unix/Linux/macOS (Bash): ```bash ./java-tests.sh - On Windows (PowerShell):
-
Integrated Development Environment (IDE):
- Open the project in an IDE such as IntelliJ IDEA or Eclipse.
- Ensure
src/is configured as the source directory andtest/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.
-
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).* - Compile both source and test files together with JUnit 4 and Hamcrest libraries on the classpath:
JavaScript test dependencies can be installed using npm:
npm installThe JavaScript test suite can then be executed using npm, Composer, or directly via Node.js from the project root directory:
-
Using npm:
npm test
2. **Using Composer**:
```bash
composer test
-
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