Skip to content

Automated Game Testing Framework Script Added #2791

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

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions Automated Game Testing Framework/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Automated Game Testing Framework

The Automated Game Testing Framework is a tool designed to help game developers efficiently test various aspects of their games, including gameplay mechanics, UI interactions, and performance. This framework provides a structured approach to writing and running automated tests, helping identify issues and ensure the quality of the game.

## Features

- Automated testing of game functions and interactions.
- Simulated game environment for testing.
- Example test cases to get started.
- Easily extensible for more complex testing scenarios.
- Integration with common testing libraries.

## Requirements

- Python
- Required Python packages (install using `pip`):

```bash
pip install unittest
```

Additional packages may be required depending on your specific testing needs.

## Getting Started

1. Clone this repository to your local machine.
2. Navigate to the project directory.

## Usage

1. Open the `game_testing_framework.py` file and customize the `Game` class with your game functions and mechanics.
2. Add more test cases and assertions as needed to thoroughly test your game.

### Running Tests

To run the tests, execute the following command:

```bash
python game_testing_framework.py
```

The tests will be executed, and the results will be displayed in the terminal.

## Advanced Usage

This framework serves as a foundation for automated testing. Depending on your game's complexity, you might need to integrate additional tools and libraries for UI testing, performance testing, and continuous integration.

## Contributing

Contributions are welcome! If you have suggestions, bug reports, or improvements, please feel free to submit an issue or a pull request.
57 changes: 57 additions & 0 deletions Automated Game Testing Framework/game_testing_framework.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import unittest

class Game:
def __init__(self):
self.is_running = False
self.score = 0

def start(self):
self.is_running = True
return "Game started."

def play(self, action):
if self.is_running:
if action == "move_forward":
self.score += 10
elif action == "attack":
self.score += 20
elif action == "use_item":
self.score += 5
return f"Performed action: {action}"
else:
return "Game is not running."

def quit(self):
self.is_running = False
return "Game quit."

class TestGame(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.game = Game()
cls.game.start()

def test_start(self):
self.assertTrue(self.game.is_running)
self.assertEqual(self.game.start(), "Game started.")

def test_actions(self):
actions = ["move_forward", "attack", "use_item"]
for action in actions:
with self.subTest(action=action):
result = self.game.play(action)
self.assertIn(action, result)
self.assertGreaterEqual(self.game.score, 0)

def test_quit(self):
self.assertTrue(self.game.is_running)
self.assertEqual(self.game.quit(), "Game quit.")
self.assertFalse(self.game.is_running)

def test_non_running_actions(self):
self.game.quit()
result = self.game.play("move_forward")
self.assertEqual(result, "Game is not running.")

if __name__ == "__main__":
unittest.main()
2 changes: 2 additions & 0 deletions Automated Game Testing Framework/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python
unittest