Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add module for writing unit tests #121

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

podocarp
Copy link
Member

@podocarp podocarp commented Dec 14, 2021

Description

Usually testing of programs in source academy is done by commenting and uncommenting code. This is a great big hassle. I have also noticed that students usually only run a single test at a time and comment/uncomment
every single line manually, which makes it even slower. Thus it would be great if we could introduce proper unit testing into Source.

This module adds a few function for writing tests and asserts, as well as a new tab to report on test statuses.
image

I have generally tried to keep to a style similar to jest.

Future extensions:

  • Compare runes, sound, etc.
  • Style the tab a bit nicer

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Added unit tests, as well as manual testing.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@podocarp podocarp self-assigned this Dec 14, 2021
@podocarp podocarp added the Enhancement [Category] New feature request label Dec 14, 2021
Copy link
Contributor

@Anonymxtrix Anonymxtrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! I think that this test module that you have written will definitely be a hit among the source academy cadets! Too bad this wasn't yet implemented when I was taking 1101s haha.

The comments I added are generally my opinion (pls don't take any offence) and feel free to contact me if you wish to discuss or argue against any of the points I wrote so that we can learn together as well! :)

modules.json Show resolved Hide resolved
src/bundles/unittest/asserts.ts Outdated Show resolved Hide resolved
src/tabs/UnitTest/index.tsx Outdated Show resolved Hide resolved
src/bundles/unittest/functions.ts Outdated Show resolved Hide resolved
@martin-henz
Copy link
Member

This PR is still marked as "draft". @podocarp: Or is it ready for final review?

@podocarp podocarp marked this pull request as ready for review March 2, 2022 02:20
@podocarp
Copy link
Member Author

podocarp commented Mar 2, 2022

Have not written docs yet, but hope someone can look at the code first.

@RichDom2185 RichDom2185 requested review from RichDom2185, leeyi45 and martin-henz and removed request for MarcusTXK April 8, 2024 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement [Category] New feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants