MuseScore/mtest
RomanPudashkin 868069c4c3
Merge pull request #8853 from Jojo-Schmitz/leland-update-master
[MU4] Fix #316152: Some characters do not print from Leland on certain printer drivers on Mac
2021-09-14 22:04:25 +02:00
..
mscore Updated license headers for cmake files 2021-04-19 17:09:37 +02:00
musicxml Updated license headers for cmake files 2021-04-19 17:09:37 +02:00
scripting moved MasterScore to separate file 2021-07-23 17:26:48 +02:00
stringutils Updated license headers for cmake files 2021-04-19 17:09:37 +02:00
testoves moved MasterScore to separate file 2021-07-23 17:26:48 +02:00
testscript Updated license headers for cmake files 2021-04-19 17:09:37 +02:00
build.xml Initial commit 2012-05-26 14:49:10 +02:00
cmake.inc Fix linking Unit Tests on macOS 2021-08-05 00:24:18 +02:00
CMakeLists.txt Got rid of Zerberus from MU4 2021-07-03 01:27:36 +03:00
config.h Updated license headers for .cpp/.h files 2021-04-19 17:08:37 +02:00
mscoreappresources.cpp Updated license headers for .cpp/.h files 2021-04-19 17:08:37 +02:00
mtest.cpp Updated license headers for .cpp/.h files 2021-04-19 17:08:37 +02:00
mtest.qrc Update Leland to 0.61 2021-08-25 12:12:33 +02:00
mtestglobals.cpp Updated license headers for .cpp/.h files 2021-04-19 17:08:37 +02:00
README.md Braille Export 2020-11-24 10:13:58 +02:00
test.mscx Update and rework certain mtests 2019-12-04 11:11:45 +02:00
testutils.cpp renamed element to engravingitem 2021-09-02 15:36:45 +02:00
testutils.h renamed element to engravingitem 2021-09-02 15:36:45 +02:00
updateReferences.sh Updated license headers in .sh files 2021-04-19 17:10:01 +02:00

Automated tests

Building & running the tests

To build all tests:

Linux OSX Windows (MinGW)
make debug
sudo make installdebug
cd build.debug/mtest
make
make -f Makefile.osx debug
make -f Makefile.osx installdebug
cd build.debug/mtest
make -f Makefile.osx
mingw32-make -f Makefile.mingw debug
mingw32-make -f Makefile.mingw installdebug
cd build.debug\mtest
mingw32-make -f Makefile
Windows (MSVC)
(Compile MuseScore in debug mode)
(Install MuseScore)
cd msvc.build_x64\mtest
cmake --build .
cmake --build . --target INSTALL

To run all tests:

ctest

To run only one test (for debugging purposes):

cd libmscore/join/
./tst_join

To see how the CI environment is doing it check .travis.yml and build/run_tests.sh

Note: You need to have diff in your path. For Windows, get a copy of diffutils for Windows.

Note-2: For Windows MSVC and MinGW you also need MuseScore installation bin folder (for example C:\MuseScore\msvc.install_x64\bin, C:\MuseScore\win32install\bin, C:\MuseScore\win64install\bin) in your path.

Note-3: For Windows, if you are running tests that use diff from Powershell, you need to first disable the default alias with del alias:diff -Force.

Test case conventions

Tests are grouped in directories by feature (like libmscore or mxl). In these directories, each subdirectory represents a test suite for a particular sub feature.

The name of a test suite directory should be descriptive. The CPP file for the tests should use the same name as the directory, for example tst_foo.cpp in directory foo. It's good practice to include a README file in a test suite directory.

Test suite CPP files contain one slot per test case. Each file should be called foo-XX with XX being an incrementing count. If a test case uses a file and a ref file, they should be called foo-XX and foo-XX-ref, with the extension .mscx. A test case should not reuse a file from another test case.

To create reference or original files, MuseScore can be run with the -t command line argument and it will save all the files in the session in test mode. Such files do not contain platform or version information and do contain extra data for tracing (for example, they contains pixel level position for beams).

How to write a test case

Import test

  • Open a short file containing an individual case in one of the formats supported by MuseScore
  • Save in MuseScore format
  • Compare with reference file

At first the test will fail because there is no reference file. Open the file created by the test case in MuseScore and try to edit it to be sure it's valid. If the file is valid, save it (without version number) as a reference file.

Object read write

Create a test case for all elements and all properties in each element. See libmscore/note.

  • Create an object
  • Set a property
  • Write and read the object
  • Check if the property has the right value

Action tests

See libmscore/join or libmscore/split for example.

  • Read a score file
  • Apply an action
  • Write the file
  • Compare with a reference
  • (Undo the action)
  • (Compare with original file)

Compatibility tests

Most of them are in mtest/libmscore/compat.

  • Read a score file from an older version of MuseScore
  • Write the file
  • Compare with a reference file