Skip to content
Snippets Groups Projects
Commit fbd8e8e4 authored by Victor Löfgren's avatar Victor Löfgren
Browse files

config: Add test coverage tasks and update readme

parent 813dd938
No related branches found
No related tags found
No related merge requests found
Pipeline #34844 passed
......@@ -2,4 +2,5 @@ __pycache__
*.db
*/env
*.coverage
htmlcov
.pytest_cache
\ No newline at end of file
......@@ -2,7 +2,7 @@
"version": "2.0.0",
"tasks": [
{
"label": "Client",
"label": "Start client",
"type": "npm",
"script": "start",
"path": "client/",
......@@ -13,7 +13,26 @@
}
},
{
"label": "Server",
"label": "Test client",
"type": "npm",
"script": "test:coverage:html",
"path": "client/",
"group": "test",
"problemMatcher": [],
},
{
"label": "Open client coverage",
"type": "shell",
"group": "build",
"command": "start ./output/coverage/jest/index.html",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/client"
},
},
{
"label": "Start server",
"type": "shell",
"group": "build",
"command": "env/Scripts/python main.py",
......@@ -26,10 +45,20 @@
}
},
{
"label": "Test Server",
"label": "Test server",
"type": "shell",
"group": "build",
"command": "env/Scripts/pytest.exe --cov-report html --cov app tests/",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/server"
},
},
{
"label": "Open server coverage",
"type": "shell",
"group": "build",
"command": "env/Scripts/pytest.exe --cov app tests/",
"command": "start ./htmlcov/index.html",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/server"
......@@ -37,7 +66,7 @@
},
{
"label": "Client + Server",
"label": "Start client and server",
"group": "build",
"dependsOn": [
"Server",
......
![coverage report](https://gitlab.liu.se/tddd96-grupp11/teknikattan-scoring-system/badges/dev/coverage.svg?job=client:test&key_text=Client+Coverage&key_width=110)
![coverage report](https://gitlab.liu.se/tddd96-grupp11/teknikattan-scoring-system/badges/dev/coverage.svg?job=server:test&key_text=Server+Coverage&key_width=115)
# Scoring system for Teknikåttan
This is the scoring system for Teknikåttan!
......@@ -13,6 +12,6 @@ To install the client and server needed to run the application, look in their re
## Using
After installing both the client and the server, you are ready to run the application.
This is done in VSCode by pressing `ctrl+shift+b` and running the `Client + Server` task.
This is done in VSCode by pressing `ctrl+shift+b` and running the `Start client and server` task.
The terminals for the client and server will now be seen on the right and left, respectively.
After making a change to either the client or the server while they are running, they will auto reload and you will see the changes immediately.
After making a change to either the client or the server while they are running, simply reload the page to see the changes immediately.
......@@ -21,3 +21,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
output
......@@ -24,32 +24,33 @@ npm install
## Using
After you have done every step described in setup, you are ready to start the client.
You can either start the client using tasks (recommended) or start it directly in the terminal.
To see the tasks described in the following steps, press `ctrl+shift+b`.
### Tasks
### Starting
You can run the client using Visual Studio Code tasks.
This is done by pressing `ctrl+shift+b` and running the `Client` task.
Start the server by running the `Start client` task.
### Terminal
### Testing
Run the client tests running the `Test client` task.
After it has finished, you can view a coverage report.
This is done by running the `Open client coverage` task.
### Adding and removing new modules
You can also run the client directly from the terminal.
All of the following snippets assume you are in the `client` folder.
Running the client:
Installing new module:
```bash
npm run start
npm install <module>
```
Installing new modules:
Uninstalling module:
```bash
npm install new_module
npm uninstall <module>
```
Whenever a new module is installed, commited and pushed to git, everyone else needs to run `npm install` after pulling to install it as well.
Author: Victor Löfgren
Last updated: 11 February 2020
......@@ -43,7 +43,8 @@
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint \"./src/**/*.{js,ts,tsx}\"",
"test:coverage": "react-scripts test --coverage --coverageDirectory=output/coverage/jest"
"test:coverage": "react-scripts test --coverage --coverageDirectory=output/coverage/jest",
"test:coverage:html": "npm test -- --coverage --watchAll=false --coverageDirectory=output/coverage/jest"
},
"browserslist": {
"production": [
......@@ -65,7 +66,8 @@
],
"coverageReporters": [
"text",
"cobertura"
"cobertura",
"html"
]
},
"proxy": "http://localhost:5000/api/"
......
......@@ -11,7 +11,7 @@ You will need to do the following things to install the server:
3. Clone this repository if you haven't done so already.
4. Open the project folder in VSCode.
5. Open the integrated terminal by pressing `ctrl+ö`.
6. Type the following commands (or if you are on Windows, simply paste them) into your terminal:
6. Type the following commands into your terminal:
```bash
# Install virtualenv package. You may need to open as administrator if you get
......@@ -29,12 +29,13 @@ py -m venv env
# This step is different depending on your operating system.
# Windows
# You migt to run the following before activating the virtual environment.
Set-ExecutionPolicy Unrestricted -Scope Process
./env/Scripts/activate
# =====
# Linux/Mac
# source env/bin/activate
source env/bin/activate
# =====
# Install all the required packages into your virtual environment.
pip install -r requirements.txt
......@@ -42,35 +43,40 @@ pip install -r requirements.txt
## Using
After you have done every step described in setup, you are ready to run the server.
You can either run the server using tasks (recommended) or run it directly in the terminal.
After you have done every step described in setup, you are ready to start the server.
To see the tasks described in the following steps, press `ctrl+shift+b`.
### Tasks
### Starting
You can run the server using Visual Studio Code tasks.
This is done by pressing `ctrl+shift+b` and running the `Server` task.
Start the server by running the `Start server` task.
### Terminal
### Testing
You can also run the server and tests directly from the terminal.
Before doing anything in the terminal, you need to activate the Python virtual environment (see Setup).
All of the following snippets assume you are in the `server` folder.
Run the client tests running the `Test server` task.
Running the server:
After it has finished, you can view a coverage report.
This is done by running the `Open server coverage` task.
### Adding and removing new packages
All of the following snippets assume you are in the `server` folder and have activated the virtual environment (see Setup).
Installing new package:
```bash
python main.py
pip install <package>
```
Running the tests:
Uninstalling package:
```bash
python test.py
pip uninstall <package>
```
Adding new packages:
If you have added or removed a package from the repository, you will also have to run the following before commiting it to git:
```bash
pip install new_package
pip freeze > requirements.txt
```
Whenever a new package is installed, commited and pushed to git, everyone else needs to run `pip install -r requirements.txt` after pulling to install it as well.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment