BCStudentSoftwareDevTeam / BCStudentSoftwareDevTeam/celts
Refactor Test Suites to Use Fixtures instead of duplicating data
- Dominant language
- Python
- Stars
- 1
- Forks
- 15
- Avg merge
- 5d 39m
- Merged PRs (30d)
- 8
Description
In the test_minor.py suite we have implemented fixtures that allow us to remove unnecessary duplicate creation statements. It would be nice if we could make this global and implement some fixtures that could be used in all functions. Since many tests might have multiple things created it could be beneficial to create `factories` which are essentially functions we can call that will create testing data. This might be an example:
```
@pytest.fixture
def userFactory():
createdUsers = []
def createUser(username):
user = User.create(username=username, firstName="Test", lastName="User", email=f"{username}@test.com")
createdUsers.append(user)
return user
yield createUser # Runs test first
for user in createdUsers:
user.delete_instance()
# usage
user1 = userFactory("FINN")
user2 = userFactory("glek")
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.