diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml new file mode 100644 index 0000000000..f85bc0e5d9 --- /dev/null +++ b/.github/workflows/unit_tests.yml @@ -0,0 +1,46 @@ +name: Run Unit Tests + + +on: + pull_request: + branches: + # GUYS ADD YOUR BRANCHES HERE: + - JasonWorking + - omarshakir8-UnitTestsDoc1 + - omarshakir8-integration-testsdoc + # - [YOUR BRANCH HERE] + push: + branches: + - main + - JasonWorking # Runs automatically when changes are pushed to 'JasonWorking' branch. You should see a check mark or an 'X'! + - omarshakir8-UnitTestsDoc1 + - omarshakir8-integration-testsdoc + # GUYS, ADD YOUR BRANCHES HERE: + # - [YOUR BRANCH HERE] + + +jobs: + test: + runs-on: ubuntu-latest + + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt # Install dependencies, including pytest + + + - name: Run tests + run: | + pytest --maxfail=1 --disable-warnings -q # Run pytest and fail after 1 failure diff --git a/Feedstack/__pycache__/numbers_test.cpython-312-pytest-8.3.4.pyc b/Feedstack/__pycache__/numbers_test.cpython-312-pytest-8.3.4.pyc new file mode 100644 index 0000000000..bb50eb8cab Binary files /dev/null and b/Feedstack/__pycache__/numbers_test.cpython-312-pytest-8.3.4.pyc differ diff --git a/Feedstack/__pycache__/unit_test.cpython-312-pytest-8.3.4.pyc b/Feedstack/__pycache__/unit_test.cpython-312-pytest-8.3.4.pyc new file mode 100644 index 0000000000..a0ce3e7bf1 Binary files /dev/null and b/Feedstack/__pycache__/unit_test.cpython-312-pytest-8.3.4.pyc differ diff --git a/Feedstack/numbers_test.py b/Feedstack/numbers_test.py new file mode 100644 index 0000000000..f223b40368 --- /dev/null +++ b/Feedstack/numbers_test.py @@ -0,0 +1,2 @@ +def add_numbers(a, b): + return a + b \ No newline at end of file diff --git a/Feedstack/requirements.txt b/Feedstack/requirements.txt index e1361c9bdb..eda170ec8e 100644 --- a/Feedstack/requirements.txt +++ b/Feedstack/requirements.txt @@ -8,4 +8,5 @@ python-dotenv scikit-learn nltk seaborn -matplotlib \ No newline at end of file +matplotlib +pytest \ No newline at end of file diff --git a/Feedstack/unit_test.py b/Feedstack/unit_test.py new file mode 100644 index 0000000000..0fc65738d3 --- /dev/null +++ b/Feedstack/unit_test.py @@ -0,0 +1,14 @@ +import pytest +from numbers_test import add_numbers + + +# Test function to check the addition of two numbers +def test_add_numbers(): + assert add_numbers(2, 3) == 5 # Test 1: Should return 5 + assert add_numbers(1, 1) == 2 # Test 2: Should return 2 + assert add_numbers(0, 0) == 0 # Test 3: Should return 0 + assert add_numbers(-1, 1) == 0 # Test 4: Should return 0 + assert add_numbers(-2, -3) == -5 # Test 5: Should return -5 + + +# To run the tests, run: pytest unit_test.py