diff --git a/Automated Game Testing Framework/README.md b/Automated Game Testing Framework/README.md new file mode 100644 index 0000000000..46be1b4066 --- /dev/null +++ b/Automated Game Testing Framework/README.md @@ -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. \ No newline at end of file diff --git a/Automated Game Testing Framework/game_testing_framework.py b/Automated Game Testing Framework/game_testing_framework.py new file mode 100644 index 0000000000..8dd6dd2470 --- /dev/null +++ b/Automated Game Testing Framework/game_testing_framework.py @@ -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() diff --git a/Automated Game Testing Framework/requirements.txt b/Automated Game Testing Framework/requirements.txt new file mode 100644 index 0000000000..69447be3c1 --- /dev/null +++ b/Automated Game Testing Framework/requirements.txt @@ -0,0 +1,2 @@ +python +unittest \ No newline at end of file