Skip to content

Commit

Permalink
Replace TESTING.md contents with link to new docs page
Browse files Browse the repository at this point in the history
  • Loading branch information
ngandrass committed Oct 10, 2024
1 parent d6a8728 commit 0c96d4e
Showing 1 changed file with 1 addition and 69 deletions.
70 changes: 1 addition & 69 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,3 @@
# Testing

**ATTENTION:** The following notes are meant **for developers only**. If you only want
to use this plugin you can fully ignore this file.


## Creating a PHPUnit test environment

See: https://moodledev.io/general/development/tools/phpunit

1. Spawn a shell inside your Moodle/php-fpm container and navigate to your
Moodle root directory:
```bash
docker exec -it my-moodle-container sh
cd /usr/share/nginx/www/moodle/
```
2. Prepare PHPUnit configuration. Add the following lines to your `config.php`:
```php
$CFG->phpunit_prefix = 'phpu_';
$CFG->phpunit_dataroot = '/path/to/your/phpunit_moodledata';
```
3. Download composer and install dev dependencies:
```bash
wget https://getcomposer.org/download/latest-stable/composer.phar
php composer.phar install
```
4. Bootstrap test environment:
```bash
php admin/tool/phpunit/cli/init.php --disable-composer
```


## Running tests

- Run all tests:
```bash
vendor/bin/phpunit --colors --testdox
```
- Run all tests for a single component:
```bash
vendor/bin/phpunit --colors --testdox --filter quiz_archiver/*
```
- Run a single test suite:
```bash
vendor/bin/phpunit --colors --testdox mod/quiz/report/archiver/tests/Report_test.php
```

### Automatic test execution for all supported software configurations

The configuration for automated test execution via GitHub CI can be found in
`.github/workflows/moodle-plugin-ci.yml`. It holds a matrix of all supported
software configurations and runs the tests for each of them.


## Generating code coverage reports

**You need to have xdebug installed and enabled in order to generate coverage
reports!**

1. Run PHPUnit with coverage report:
```bash
XDEBUG_MODE=coverage vendor/bin/phpunit --colors --testdox --coverage-html /tmp/coverage --filter quiz_archiver/*
```
2. Copy the generated report to your machin:
```bash
docker cp my-moodle-container:/tmp/coverage /tmp/coverage
```
3. Open the report in your browser:
```bash
xdg-open /tmp/coverage/index.html
```
See: https://quizarchiver.gandrass.de/development/unittests/

0 comments on commit 0c96d4e

Please sign in to comment.