Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
467ce23d
Commit
467ce23d
authored
1 year ago
by
Michele Alberti
Browse files
Options
Downloads
Patches
Plain Diff
[ivette/tests] Rework part of README. To be completed.
parent
20cbc8d5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ivette/playwright.config.ts
+1
-1
1 addition, 1 deletion
ivette/playwright.config.ts
ivette/tests/README.md
+66
-34
66 additions, 34 deletions
ivette/tests/README.md
with
67 additions
and
35 deletions
ivette/playwright.config.ts
+
1
−
1
View file @
467ce23d
...
...
@@ -33,7 +33,7 @@ import { defineConfig, devices } from '@playwright/test';
*/
export
default
defineConfig
({
testDir
:
'
./tests
'
,
/* Run tests in files in parallel */
/* Run tests in files in parallel
(set to false to avoid concurrency issues with Electron)
*/
fullyParallel
:
false
,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly
:
!!
process
.
env
.
CI
,
...
...
This diff is collapsed.
Click to expand it.
ivette/tests/README.md
+
66
−
34
View file @
467ce23d
# How to execute e2e tests and monkey testing with Playwright
This document presents the framework for testing Ivette by describing its
overall architecture, and how to launch current tests and write new ones.
Official documentation:
## Overall Architecture
-
Playwright:
<https://playwright.dev/>
-
Gremlins.js:
<https://github.com/marmelab/gremlins.js>
The framework is based on two main testing libraries:
Playwright has native support for Electron applications. Examples on how to
launch Ivette with Frama-C's server are provided in
`e2eService.ts`
file, along
with an example loading a C file.
-
`Playwright`
:
<https://playwright.dev/>
-
`Gremlins.js`
:
<https://github.com/marmelab/gremlins.js>
However:
`Playwright`
is meant for end-to-end (e2e) testing, i.e. for testing specific
behaviors, while
`Gremlins.js`
provides monkey testing, i.e. robustness/stress
testing of the entire application.
-
to have electron support (needed for Ivette), you need to build the
`tests`
directory using
`make tests`
from the
`ivette`
directory
-
if you want to connect to the Frama-C server, Frama-C needs to be built using
`make`
from the
`frama-c`
directory.
Here is how the framework is organized:
In the provided tests, various path are provided within
`e2eService.ts`
to launch
Ivette with Frama-C or with additionnal C files. Those can be modified at will,
however it is recommanded to stick with relative paths for maintenability.
-
`e2e/`
contains the end-to-end tests,
-
`monkey/`
cointains the monkey tests,
-
`lib/`
contains utilities for writing tests using the
`Playwright`
infrastructure. These utilities are used both for e2e and monkey testing.
##
Launch
ing tests
##
Execut
ing tests
From
`ivette`
directory:
To launch a specific test with
`yarn playwright test <file-name>`
;
exemple:
`yarn playwright test tests/e2e-playwright/launch-app.spec.ts`
To launch all tests from a specific folder
`yarn playwright test <folder>`
;
exemple:
`yarn playwright test tests/e2e-playwright/monkey`
To launch ALL tests with
`yarn playwright test`
;
For more options such as headless mode,
or to launch a test with a specific title,
refer to the Playwright
**Requirement:**
In order to execute the tests, Frama-C has to be built
beforehand.
Testing Ivette, in terms of both the e2e and monkey tests, amounts to the
execution of the following commands from the Frama-C root directory:
```
$ make // builds Frama-C, if not already
$ cd ivette
$ make tests // builds Ivette and execute all tests
```
To execute the e2e tests only, the last command to execute is the following:
```
$ make tests-e2e
```
To execute the monkey tests only, the last command to execute is the following:
```
$ make tests-monkey
```
## Executing tests (Advanced)
Whenever the execution of the tests does not need (re-)building Ivette, one can
directly do the following from the Ivette root directory:
```
$ dune exec -- yarn playwright test
```
This is also useful for executing just a (list of) test(s). In such a case, do
the following from the Ivette root directory:
```
$ dune exec -- yarn playwright test /path/to/test1 /path/to/test2
```
For more information, refer to the
`Playwright`
[
documentation
](
https://playwright.dev/docs/running-tests
)
.
## Accessing tests report
If the test fails, Playwright will automatically open its report.
To manually access the last report:
Upon a test failure,
`Playwright`
informs about the failing step, or assertion,
with a message on the console. This should be sufficient to debug the failure.
However,
`Playwright`
also writes down a report of the failure that can be
accessed as follows from the Ivette root directory:
-
From
`ivette`
directory, use
`yarn playwright show-report`
,
then access
`localhost:9323`
in a browser ;
```
$ yarn playwright show-report
```
Playwright options can me modified within its
configuration file
`playwright.config.ts`
.
The
`fullyParallel`
option has been set to false, as this feature resulted
in concurency issues with Electron.
The previous command should open a browser tab showing the last recorded report;
if not, such a report should be available at
`http://localhost:9323`
.
## Writing test
file
s
## Writing tests
Playwright uses its Locator system to select html elements. You can type your own,
but Playwright can help with that aswell. Inside a test, add
`await window.pause()`
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment