What I'm going to outline here are the steps which need to be performed in order to launch a test of some JBox2D modelled, physics behaviour. The full code for which can be found on GitHub.
As highlighted in the Adding Tests/Settings section of the documentation, we need an entry point to perform the following, high-level, tasks:
- Instantiate an instance of the Testbed
- Add our test(s)
- Launch the Testbed's GUI
The first thing that wasn't immediately clear from the online documentation, but that was cleared up by the codebase is that our entry point (we'll call it TestbedMain) is not a JUnit test, but a Java class with a Main method. The online documentation/example seems to be a bit out of date - below is the complete code for my TestbedMain class:
The MJWTest2 class (seen referenced in the code above) is the test which we want to run, and the code for which is almost copied verbatim from the A Simple Test section of the documentation, with the exclusion of the following line which does not compile:
It's also likely at this point that your TestbedMain class does not compile because of the missing libraries/dependencies. I used Maven to manage these dependencies, and I think that this is the easiest way - the following dependency needs to be added to your pom.xml file:
You could, however, just add the dependencies' JAR files to the project by hand if you don't want to use Maven - here's a view of the dependencies needed:
You should then be able to execute the Main method of the TestbedMain class, and you will see the sample test started in the Testbed's GUI:
The full code for this simple project can be found on GitHub.
Prev (Getting started with JBox2D) Next (Modelling simple physics behaviour)
It's also likely at this point that your TestbedMain class does not compile because of the missing libraries/dependencies. I used Maven to manage these dependencies, and I think that this is the easiest way - the following dependency needs to be added to your pom.xml file:
You could, however, just add the dependencies' JAR files to the project by hand if you don't want to use Maven - here's a view of the dependencies needed:
You should then be able to execute the Main method of the TestbedMain class, and you will see the sample test started in the Testbed's GUI:
The full code for this simple project can be found on GitHub.
Prev (Getting started with JBox2D) Next (Modelling simple physics behaviour)
No comments:
Post a Comment