Skip to content

Commit

Permalink
added comments and readme (issue #5)
Browse files Browse the repository at this point in the history
  • Loading branch information
PattonYin committed Dec 6, 2023
1 parent 7c06769 commit 54b2c81
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 4 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
67 changes: 63 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,70 @@
In addition to the back up, we also have codes related to Unit Testing and Continuous Integration(Python pytest, Jest, PHPUnit, GitHub Actions, Generative AI) for COMP 333: Software Engineering 2023
Homework 5

## Python test

## Python
```pip install pytest```
### Problem 1 (unit test without pytest)

Please run the code at PythonCode/problem1.py (Through terminal)

```
python -u "PythonCode/problem1.py"
```

### Problem 2 (unit test with pytest)

How to set up the environment: (Through terminal)

```
pip install pytest
```

Run the test: (Through terminal)

```
pytest
```

## Backend Test

## Backend
### Environment Config
### Hard code id; username; password

Please setup the phpunit following testing-tutorial on class website.

### How to run

Navigate to the backend folder of backend

```
cd backend
./vendor/bin/phpunit tests/StackTest.php
```

### Hard coded id (song_id), username, password

For testRegister, testLogin, testFailLogin:
the unsername and password are hard coded, make sure such user doesn't exist in the database before the test.

```
'username' => 'test_admin',
'password' => '1234567890aaa',
```

In the testUpdateSong and testDeleteSong tests, we use the song_id as a parameter to identify the specific song we want to update or delete. This song_id is automatically generated and incremented in our SQL database whenever a new song is added.

Therefore, when writing or updating these tests, it's crucial to ensure that the song_id used in the test matches the song_id of the song you expect to be present in the database. This is because the song_id in the database will automatically increment each time a new song is added.

In other words, if you're writing a test to update or delete a song that you've just inserted into the database for testing purposes, you need to know the song_id that was assigned to that song and use it in your test. If the song_id in the test doesn't match any song_id in the database, the test will fail because it can't find the song it's supposed to update or delete.

```
'id' => '53',
'username' => 'test_admin',
'song_artist' => 'test_admin',
'song_name' => 'admin_song',
'song_rating' => '4',
```

```
'id' => '53',
'username' => 'test_admin',
```

0 comments on commit 54b2c81

Please sign in to comment.