| 12345678910111213141516171819202122232425262728 |
- <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]--><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="Asciidoctor 1.5.4"><meta name="keywords" content="documentation, sdk, tool"><title>jMonkeyEngine SDK: Debugging, Profiling, Testing</title><link rel="stylesheet" href="./asciidoctor.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
- <link rel="stylesheet" href="./coderay-asciidoctor.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"></head><body class="article toc2 toc-left"><div id="header"><div id="toolbar"><a href="https://github.com/jMonkeyEngine/wiki/edit/master/src/docs/asciidoc/sdk/debugging_profiling_testing.adoc"><i class="fa fa-pencil-square" aria-hidden="true"></i></a><a href="https://github.com/jMonkeyEngine/wiki/new/master/src/docs/asciidoc/sdk/"><i class="fa fa-plus-square" aria-hidden="true"></i></a><input dir="auto" style="position: relative; vertical-align: top;" spellcheck="false" autocomplete="off" class="searchbox__input aa-input" id="doc-search" name="search" placeholder="Search in the doc" required="required" type="search"><i class="fa fa-navicon" aria-hidden="true"></i></div><h1>jMonkeyEngine SDK: Debugging, Profiling, Testing</h1><div class="details"><span class="author" id="author"></span><br><span id="revnumber">version ,</span> <span id="revdate">2016/03/17 20:48</span></div><div id="toc" class="toc2"><div id="toctitle">Table of Contents</div><ul class="sectlevel1"><li><a href="#testing">Testing</a><ul class="sectlevel2"><li><a href="#creating-tests">Creating Tests</a></li><li><a href="#running-tests">Running Tests</a></li></ul></li><li><a href="#debugging">Debugging</a></li><li><a href="#profiling">Profiling</a><ul class="sectlevel2"><li><a href="#installing-the-profiler">Installing the Profiler</a></li><li><a href="#monitoring-and-analyzing">Monitoring and Analyzing</a></li><li><a href="#comparing-snapshots">Comparing Snapshots</a></li><li><a href="#using-profiling-points">Using Profiling Points</a></li></ul></li></ul></div></div><div id="content"><div id="preamble"><div class="sectionbody"><div class="paragraph"><p>Debugging, testing and profiling are important parts of the development cycle. This documentation shows you how to make the most of the jMonkeyEngine SDK’s assistive features.</p></div>
- <div class="admonitionblock tip"><table><tr><td class="icon"><i class="fa icon-tip" title="Tip"></i></td><td class="content"><div class="paragraph"><p>Since the jMonkeyEngine SDK is based on the NetBeans IDE and the NetBeans Platform, you can learn about certain jMonkeyEngine SDK features by reading the corresponding NetBeans IDE tutorials (in the “see also links).</p></div></td></tr></table></div></div></div>
- <div class="sect2"><h3 id="testing">Testing</h3><div class="paragraph"><p>The jMonkeyEngine SDK supports the JUnit testing framework. It is a good practice to write tests (assertions) for each of your classes. Each test makes certain this “unit (e.g. method) meets its design and behaves as intended. Run your tests after each major change and you immediately see if you broke something.</p></div>
- <div class="sect2"><h3 id="creating-tests">Creating Tests</h3><div class="olist arabic"><ol class="arabic"><li><p>Right-click a Java file in the Projects window and choose Tools > Create JUnit Tests.</p></li><li><p>Click OK. The jMonkeyEngine SDK creates a JUnit test skeleton in the Test Package directory.</p></li><li><p>The body of each generated test method is provided solely as a guide. In their place, you need to write your actual test cases!</p></li><li><p>You can use tests such as <code>assertTrue(), assertFalse(), assertEquals()</code>, or <code>assert()</code>.</p><div class="ulist"><ul><li><p>The following example assertions test an addition method: <code>assert( add(1, 1) == 2); assertTrue( add(7,-5) == add(-5,7) )…</code></p></li></ul></div></li><li><p>“Ideally, you write a test case for every method (100% coverage).</p></li></ol></div>
- <div class="admonitionblock tip"><table><tr><td class="icon"><i class="fa icon-tip" title="Tip"></i></td><td class="content"><div class="paragraph"><p>Use the Navigate menu to jump from a test to its tested class, and back!</p></div></td></tr></table></div></div>
- <div class="sect2"><h3 id="running-tests">Running Tests</h3><div class="olist arabic"><ol class="arabic"><li><p>Run one or all tests:</p><div class="ulist"><ul><li><p>Right-click the class in the Projects window and Choose Test File, or</p></li><li><p>Right-click the project and select Test to run all tests.</p></li></ul></div></li><li><p>Check the Test window to see successful tests (green) and failures (red).</p></li><li><p>If a test fails that has succeeded before, you know that your latest changes broke something!</p></li></ol></div>
- <div class="paragraph"><p>Using unit tests regularly allows you to detect side-effects on classes that you thought were unaffected by a code change.</p></div>
- <div class="paragraph"><p>See also:</p></div>
- <div class="ulist"><ul><li><p><a href="http://netbeans.org/kb/docs/java/junit-intro.html">Writing JUnit Tests</a></p></li><li><p><a href="http://www.junit.org">http://www.junit.org</a></p></li><li><p><a href="https://docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html">Java Assertions</a></p></li></ul></div></div></div>
- <div class="sect1"><h2 id="debugging">Debugging</h2><div class="sectionbody"><div class="paragraph"><p>In the jMonkeyEngine SDK, you have access to a debugger to examine your application for errors such as deadlocks and NullPointerExeptions. You can set breakpoints, watch variables, and execute your code line-by-line to identify the source of a problem.</p></div>
- <div class="olist arabic"><ol class="arabic"><li><p>First, you set breakpoints and/or watches before the problematic lines of code where you suspect the bug.</p><div class="ulist"><ul><li><p>If you want to watch a variable’s value: Right-click on a variable and select New Watch from the context menu.</p></li><li><p>If you want to step through the execution line by line: Right-click on a line and choose Toggle Line Breakpoint; a pink box appears as a mark.</p></li></ul></div></li><li><p>Choose “Debug > Debug Main Project to start a debugger session for the whole project. Or, right-click a file and select Debug File to debug only one file.</p></li><li><p>The application starts running normally. If you have set a breakpoint, the execution stops in this line. Debugger windows open and print debugger output.</p></li><li><p>You can do many things now to track down a bug:</p><div class="ulist"><ul><li><p>Inspect the values of local variables.</p></li><li><p>Use the Step buttons in the top to step into, out of, and over expressions while you watch the execution.</p></li><li><p>Navigate through your application’s call stack. Right-click on threads to suspend or resume them.</p></li><li><p>Choose Debug > Evaluate Expression from the menu to evaluate an expression.</p></li><li><p>Move the mouse pointer over a variable to inspect its value in a tooltip.</p></li><li><p>Inspect the classes loaded on the heap and the percentage and number of object instances. Right-click a class in the Loaded Classes window and choose Show in Instances view (JDK 6 only).</p></li><li><p>And more…</p></li></ul></div></li><li><p>To stop debugging, choose Debug > End Debugger Session from the menu.</p></li></ol></div></div></div>
- <div class="sect2"><h3 id="profiling">Profiling</h3><div class="paragraph"><p>The profiler tool is used to monitor thread states, CPU performance, and memory usage of your jme3 application. It helps you detect memory leaks and bottlenecks in your game while it’s running.</p></div>
- <div class="sect2"><h3 id="installing-the-profiler">Installing the Profiler</h3><div class="paragraph"><p>If you do not see a Profiler menu in the jMonkeyEngine SDK, you need to download the Profiler plugin first.</p></div>
- <div class="olist arabic"><ol class="arabic"><li><p>Open the Tools > Plugins menu, and got to the “Available plugins tab</p></li><li><p>Find the “Java Profiler plugin (“Java SE category) and check the Install box.</p></li><li><p>Click the install button and follow the instructions.</p></li><li><p>When you start the profiler for the first time, you are prompted to run a calibration once. Click OK in the “Profiler integration dialog to complete the installation process.</p></li></ol></div></div>
- <div class="sect2"><h3 id="monitoring-and-analyzing">Monitoring and Analyzing</h3><div class="olist arabic"><ol class="arabic"><li><p>Choose Profile Project from the Profile menu.</p></li><li><p>Select one of three tasks:</p><div class="ulist"><ul><li><p><strong>Monitor Application</strong> – Collect high-level information about properties of the target JVM, including thread activity and memory allocations.</p></li><li><p><strong>Analyze CPU Performance</strong> – Collect detailed data on application performance, including the time to execute methods and the number of times the method is invoked.</p></li><li><p><strong>Analyze Memory Usage</strong> – Collect detailed data on object allocation and garbage collection.</p></li></ul></div></li><li><p>Click Run. Your application starts and runs normally.</p></li><li><p>Use the Profiling window to track and collect live profiling results while you application is running.</p></li></ol></div></div>
- <div class="sect2"><h3 id="comparing-snapshots">Comparing Snapshots</h3><div class="paragraph"><p>Click the Take Snapshot button to capture the profiling data for later!</p></div>
- <div class="ulist"><ul><li><p>You can store and view snapshots in the Profiling window.</p></li><li><p>Choose Compare Snapshots from the profiler window to compare two selected snapshots</p></li></ul></div></div>
- <div class="sect2"><h3 id="using-profiling-points">Using Profiling Points</h3><div class="paragraph"><p>Profiling points are similar to debugger breakpoints: You place them directly in the source code and they can trigger profiling behaviour when hit.</p></div>
- <div class="ulist"><ul><li><p>Open a class in the browser, right-click in a line, and select Profiling > Insert Profiling Point to add a profiling point here.</p></li><li><p>Use Profiling points if you need a trigger to reset profiling results, take a snapshot or heap dump, record the timestamp or execution time of a code fragment, stop and start a load generator script (requires the load generator plugin).</p></li><li><p>Open the Profiling Points window to view, modify and delete the Profiling Points in your projects.</p></li></ul></div>
- <div class="paragraph"><p>See also:</p></div>
- <div class="ulist"><ul><li><p><a href="http://netbeans.org/kb/docs/java/profiler-intro.html">Introduction to Profiling Java Applications (netbeans.org)</a></p></li><li><p><a href="http://netbeans.org/kb/docs/java/profiler-profilingpoints.html">Using Profiling Points (netbeans.org)</a></p></li></ul></div></div></div></div><div id="footer"><div id="footer-text">Version <br>Last updated 2017-10-09 23:30:27 +00:00</div></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script><script>docsearch({
- apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
- indexName: 'jmonkeyengine',
- inputSelector: '#doc-search',
- debug: false // Set debug to true if you want to inspect the dropdown
- });</script></body></html>
|