Skip to content

Test and coverage

We have unit tests, regression tests, and feature tests for quality assurance.

Directory structure

We have tests under test/ directory. There are several test data in test/data/ directory. There are two type of tests.

  1. Unit tests
  2. Linting tests

Test coverage

OmegaT project prepare JaCoCo test suite to check test coverage.

When you use IDE such as IntelliJ IDEA or Eclipse, please access Gradle task menu from verification group to launch jacocoTestReport task. Otherwise, you can run it from terminal ./gradlew jacocoTestReport

A test report will be appeared in build/reports/jacoco/html/index.html and you can examine the result on your web browser.

SpotBugs static analysis tool

You are recommend to check your code with SpotBugs static analysis tool. We check it on CI/CD environment for every commit. We treat all SpotBugs issues as error.

You should fix all the SpotBugs errors before posting the patch to core team. When you push a GitHub Pull-Request, we always check unit tests and spotbugs test.

You can run spotbugs through verification task group of IDE's Gradle tasks menu and click SpotbugsMain. Otherwise, you can run it on terminal ./gradlew spotbugsMain

A test result will be appeared in build/reports/spotbugs/main.html.

Unit tests

You are recommended to write unit tests when you modify or add features anywhere in OmegaT code. Test codes are organized in several sections/packages.

  • core
  • filters
  • gui
  • languagetools
  • tokenizer
  • util

TestCore and TestCoreInitializer

There are two core test classes to perform headless test cases.

TestCore class

TestCore class provide a setUpCore method to setup temporal omegat configuration and dummy GUI parts such as dummy main window, dummy menu items and dummy editor panes.

Test writer can inherit TestCore class and then concentrate to write actual cases.

GUI tests

Unit test for GUI is a bit difficult to write. Many test cases use SwingUtilities#invokeAndWait to change or get GUI properties. Then it assert its value.

Filter tests

Filter writer are strongly recommended to write tests with variety of source files. You are also recommended to write tests with variety of options combinations.

Linting tests

There are linting test cases under test/src/svn/ directory, where the name come from histrical reason, our project managed the code on subversion repository from the start year 2002 to 2015.

We have three type of tests.

Test class Note
BundleTest Check Bundle*.properties and shortcut properties
CopyrightTest Check copyright header
PluginsTest Check plugin properties integrity