Skip to content

Commit 8d71c8b

Browse files
Automated Game Testing Framework Script Added
1 parent a946567 commit 8d71c8b

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Automated Game Testing Framework
2+
3+
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.
4+
5+
## Features
6+
7+
- Automated testing of game functions and interactions.
8+
- Simulated game environment for testing.
9+
- Example test cases to get started.
10+
- Easily extensible for more complex testing scenarios.
11+
- Integration with common testing libraries.
12+
13+
## Requirements
14+
15+
- Python
16+
- Required Python packages (install using `pip`):
17+
18+
```bash
19+
pip install unittest
20+
```
21+
22+
Additional packages may be required depending on your specific testing needs.
23+
24+
## Getting Started
25+
26+
1. Clone this repository to your local machine.
27+
2. Navigate to the project directory.
28+
29+
## Usage
30+
31+
1. Open the `game_testing_framework.py` file and customize the `Game` class with your game functions and mechanics.
32+
2. Add more test cases and assertions as needed to thoroughly test your game.
33+
34+
### Running Tests
35+
36+
To run the tests, execute the following command:
37+
38+
```bash
39+
python game_testing_framework.py
40+
```
41+
42+
The tests will be executed, and the results will be displayed in the terminal.
43+
44+
## Advanced Usage
45+
46+
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.
47+
48+
## Contributing
49+
50+
Contributions are welcome! If you have suggestions, bug reports, or improvements, please feel free to submit an issue or a pull request.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import unittest
2+
3+
class Game:
4+
def __init__(self):
5+
self.is_running = False
6+
self.score = 0
7+
8+
def start(self):
9+
self.is_running = True
10+
return "Game started."
11+
12+
def play(self, action):
13+
if self.is_running:
14+
if action == "move_forward":
15+
self.score += 10
16+
elif action == "attack":
17+
self.score += 20
18+
elif action == "use_item":
19+
self.score += 5
20+
return f"Performed action: {action}"
21+
else:
22+
return "Game is not running."
23+
24+
def quit(self):
25+
self.is_running = False
26+
return "Game quit."
27+
28+
class TestGame(unittest.TestCase):
29+
@classmethod
30+
def setUpClass(cls):
31+
cls.game = Game()
32+
cls.game.start()
33+
34+
def test_start(self):
35+
self.assertTrue(self.game.is_running)
36+
self.assertEqual(self.game.start(), "Game started.")
37+
38+
def test_actions(self):
39+
actions = ["move_forward", "attack", "use_item"]
40+
for action in actions:
41+
with self.subTest(action=action):
42+
result = self.game.play(action)
43+
self.assertIn(action, result)
44+
self.assertGreaterEqual(self.game.score, 0)
45+
46+
def test_quit(self):
47+
self.assertTrue(self.game.is_running)
48+
self.assertEqual(self.game.quit(), "Game quit.")
49+
self.assertFalse(self.game.is_running)
50+
51+
def test_non_running_actions(self):
52+
self.game.quit()
53+
result = self.game.play("move_forward")
54+
self.assertEqual(result, "Game is not running.")
55+
56+
if __name__ == "__main__":
57+
unittest.main()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
python
2+
unittest

0 commit comments

Comments
 (0)