Skip to content
inetsoft-technologyPublic

About

include all module auto testing

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

DataTest Summary

Used for performing auto tests on various modules. All modules are not installed to local repository.

Project Structure

This is a Maven multi-module project containing the following test modules:

  • commons - Common test utilities module
  • dbmatrix - The same scenarios on every test database (not in the default build, run by hand, see below)
  • chart - Chart testing module
  • css - CSS style testing module
  • docker - Docker related testing module
  • mv - MV testing module
  • olap - OLAP testing module
  • tabular - Tabular testing module
  • vpm - VPM testing module
  • vsexport - VS export testing module
  • vsothers - VS other features testing module (contains multiple test modes)
  • vsscript - VS script testing module
  • ws - Worksheet testing module

Compile and Run Tests

Configure License Key

The project requires a license key to run tests. You can configure it in the following ways:

Option 1: Command Line Parameter

Pass the license key directly via command line:

# Windows PowerShell
.mvnw.cmd test -pl vsscript -Dinetsoft.license.key="your-license-key"

# Linux/Mac bash
./mvnw test -pl vsscript -Dinetsoft.license.key="your-license-key"

Option 2: Environment Variable

Set the license key as an environment variable:

# Windows PowerShell
$env:INETSOFT_LICENSE_KEY = "your-license-key"
.mvnw.cmd test -pl vsscript

# Windows CMD
set INETSOFT_LICENSE_KEY=your-license-key
mvnw.cmd test -pl vsscript

# Linux/Mac bash
export INETSOFT_LICENSE_KEY="your-license-key"
./mvnw test -pl vsscript

Initialize Environment

First, clean all projects, then package the commons module to your local Maven repository:

.\mvnw.cmd clean
.\mvnw.cmd package -pl commons

Execute Tests for Different Modules

1. Modules with Single Test Mode

The following modules have only one test mode and can be executed directly:

# Worksheet tests
.\mvnw.cmd test -pl ws

# Chart tests
.\mvnw.cmd test -pl chart

# CSS tests
.\mvnw.cmd test -pl css

# OLAP tests
.\mvnw.cmd test -pl olap

# Tabular tests
.\mvnw.cmd test -pl tabular

# VPM tests
.\mvnw.cmd test -pl vpm

# VS export tests
.\mvnw.cmd test -pl vsexport

# VS script tests
.\mvnw.cmd test -pl vsscript

2. Modules with Multiple Test Modes (vsothers, mv)

The vsothers module contains multiple test modes. Use the -P parameter to specify the profile:

# VSCalc tests
.\mvnw.cmd test -pl vsothers -Pvscalc

# VSCrosstab tests
.\mvnw.cmd test -pl vsothers -Pvscrosstab

# VSFreehand tests
.\mvnw.cmd test -pl vsothers -Pvsfreehand

# VSPara tests
.\mvnw.cmd test -pl vsothers -Pvspara

# OtherAssembly tests
.\mvnw.cmd test -pl vsothers -Potherassembly

The mv module also has one profile per test mode. Without -P only topmv runs.

.\mvnw.cmd test -pl mv -Ptopmv
.\mvnw.cmd test -pl mv -Psubmv
.\mvnw.cmd test -pl mv -Pincrementalmv
.\mvnw.cmd test -pl mv -Pvpm
.\mvnw.cmd test -pl mv -Pothers
.\mvnw.cmd test -pl mv -Pwsmv

wsmv runs one path through a worksheet MV (WSMV_Path_Spec): it turns ws.mv.enabled on, creates the MV for the worksheet only, checks that the viewsheet reads it, and updates it incrementally. Like IncrementalDataChange_Spec it changes the H2 file, see below.

The profiles share the MV storage under mv/target. When running several of them one after another locally, delete mv/target before each one, or rows left by the previous profile make results differ.

The others profile runs every spec class in its own JVM (mv.reuseForks=false). With -Dmv.compare=nomv or both, the whole profile in one JVM fills the 2 GB heap at VSActions_Spec and stops in XSwapper.waitForMemory. Add -Dmv.reuseForks=true to run it in one JVM; set it to false to do the same in another profile.

-Dmv.compare selects how the MV results are checked:

  • golden (default): compare with expectData.
  • nomv: in the cases that call MVTest.executeVSWithoutMV (in topmv, submv, vpm and others), run the viewsheet before its MV is created and compare every exported file with the result read from the MV (MVTest.compareWithoutMV), instead of expectData. The files without MV end with __NoMV.txt. The other cases, and the files of an incremental update, are still compared with expectData.
  • both: both checks.
.\mvnw.cmd test -pl mv -Ptopmv "-Dmv.compare=nomv"

nomv only shows that the MV does not change the result. A bug shared by the MV and the database paths gives the same wrong result twice, and only expectData finds it. It is not used in incrementalmv: MV delete conditions and incremental updates make the MV hold different rows than the database on purpose. Incremental results are compared with expectData, except in IncrementalDataChange_Spec, which compares them with an MV rebuilt on the final data (MVTest.compareWithRebuild) or with the rows it expects.

IncrementalDataChange_Spec (in incrementalmv) creates and drops tables in the H2 database docker/src/test/resources/H2Data/mvorder1.mv.db, and H2 rewrites the file even though the tables are dropped. Restore it before committing:

git checkout -- docker/src/test/resources/H2Data/

3. dbmatrix Module: Every Test Database, Run by Hand

dbmatrix runs the same scenarios on every test database server (Oracle, MySQL, Derby, PostgreSQL, SQL Server, DB2, Informix, and ClickHouse and H2 for their own samples) and compares the result pushed down to SQL with the same operation computed in memory. Today it holds worksheet specs (WSMultiDB_Spec: cross-database samples and dialect checks; WSPair_Spec, WSPairDst_Spec: pushed / in-memory pairs). Viewsheet specs for the same comparison will be added here. The cases and test points (case × database, column type × operator) are listed in dbmatrix/README.md; update it when cases change.

It is slow (more than an hour) and needs all database servers, so it is not part of the default build (mvnw test without -Pdbmatrix does not build it) and its GitHub workflow (DBMatrix Module Tests, test-dbmatrix.yml) only runs when started by hand. Run it:

  • once for each new stylebi version, and before a release;
  • when stylebi changes SQL generation, a database dialect (sqlhelper.xml, the SQL helpers), what is pushed down to the database, conditions, date grouping, joins or aggregates;
  • when a bug found by these specs is fixed (update the baseline or remove the WSPair_Spec ALLOWED entry; the spec fails on an entry that no longer differs);
  • after changing the test database servers or their data.
.\mvnw.cmd test -Pdbmatrix -pl dbmatrix

# only some databases of the pair specs
.\mvnw.cmd test -Pdbmatrix -pl dbmatrix "-Dtest=WSPair_Spec,WSPairDst_Spec" "-Dpair.dbs=MySQL,Oracle"

Its worksheets are in dbmatrix/src/test/resources/config/dbmatrix-storage.zip, generated by the scripts in .claude/workflow-shared/datatest-gap/ (zip chain in its README; ws_dbmatrix_split.py derives the ws zip from it).

4. Date Comparison Specs: Strict Checks and Updating Baselines

DateComparison_Spec (chart) and Crosstab_DateComparsion_Spec (vsothers, run with -Pvscrosstab) use DcViewsheetTest instead of ViewsheetTest:

  • an export failure fails the test (it is only printed in ViewsheetTest);
  • when no file names are given, every .txt and .png file under the case's expectData folder must have been exported by the run;
  • exportAsPDF exports the (Home) bookmark by default.

To update the baselines, add -Dupdate.baseline=true. The exported files are copied into the module's src/test/resources/expectData and nothing is compared. Review the result with git diff.

# update the data (txt) baselines of one case
.\mvnw.cmd test -pl chart "-Dtest=DateComparison_Spec#Quarter_SameWeek" -Dupdate.baseline=true

# also overwrite existing png baselines
.\mvnw.cmd test -pl chart "-Dtest=DateComparison_Spec#Quarter_SameWeek" -Dupdate.baseline=true -Dupdate.baseline.png=true

A .txt baseline is always written. A .png baseline is only written when it is missing, unless -Dupdate.baseline.png=true is set, because pngs rendered on another platform differ on pixels. A baseline that is no longer exported is not deleted: remove it by hand. Run mvnw clean before a run after removing baselines, otherwise the old copy in target/test-classes/expectData is still checked.

Other Commonly Used Commands

# Clean specific module
.\mvnw.cmd clean -pl vsothers -Pvscalc

# Generate test resources (debug mode)
.\mvnw.cmd generate-test-resources -pl vsothers -Pvscalc -X

# Package (skip tests)
.\mvnw.cmd package -DskipTests -pl ws

View Test Results

After tests complete, you can view test results in the following ways:

1. Spock Test Reports

Test reports are located in the target/spock-reports directory of each module:

<module-name>/target/spock-reports/index.html

For example:

  • ws/target/spock-reports/index.html
  • vsothers/target/spock-reports/index.html

Open the index.html file in a browser to view detailed test reports.

2. Surefire Test Reports

JUnit format test reports are located in the target/surefire-reports directory of each module:

<module-name>/target/surefire-reports/

This directory contains:

  • TEST-*.xml - JUnit XML format test results
  • *.txt - Test output logs

Git Workflow

1. Create Branch

# Create new branch from main
git checkout -b feature/your-feature-name

2. Commit Changes

# Add files to staging area
git add <file-name>
# Or add all changes
git add .

# Commit changes
git commit -m "Describe your changes"

3. Push Branch

# Push branch to remote
git push -u origin feature/your-feature-name

4. Create Pull Request (PR)

After pushing your branch, on your Git hosting platform (GitHub, GitLab, etc.):

  1. Go to the repository page
  2. You'll usually see a prompt "Compare & pull request", click it
  3. Or manually:
    • Click the "Pull Requests" tab
    • Click "New Pull Request"
    • Select your branch and target branch (usually main)
    • Fill in PR title and description
    • Add reviewers (if needed)
    • Click "Create Pull Request"

Important Notes

  1. commons Module: Must package the commons module before running any tests
  2. Test Resources: Ensure test resource files (config files, test data) are correctly placed
  3. Java Version: Project requires Java 21
  4. Memory Settings: Some tests may require large memory. If encountering out-of-memory errors, adjust JVM parameters

Testcontainers Configuration

The project supports using Testcontainers to automatically start database containers for testing. This is controlled by the use.testcontainers parameter.

Enable Testcontainers

Add the -Duse.testcontainers=true parameter when running tests:

# Windows PowerShell
.mvnw.cmd test -pl vsothers -Pvscalc -Duse.testcontainers=true

# Linux/Mac bash
./mvnw test -pl vsothers -Pvscalc -Duse.testcontainers=true

Hosts File Configuration

When use.testcontainers=true, you need to add the following entries to your system's hosts file to map database hostnames to localhost.

Example:

127.0.0.1 mysql_server
127.0.0.1 db2_server

Note: The actual hostnames depend on the databases used in your specific tests. Please refer to your test case configurations to determine which host entries are required.

Windows

Edit the file C:\Windows\System32\drivers\etc\hosts with administrator privileges.

Linux/Mac

Edit the file /etc/hosts with sudo:

sudo nano /etc/hosts

Disable Testcontainers

By default, Testcontainers is disabled (use.testcontainers=false). Tests will use pre-configured database connections instead of starting containers.

Docker Environment Testing

Docker environment testing configuration is pending (@TODO)

About

include all module auto testing

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages