Author: pmouawad
Date: Tue Nov 21 08:00:06 2017
New Revision: 1815881

URL: http://svn.apache.org/viewvc?rev=1815881&view=rev
Log:
Enable running of JUnit tests from within IntelliJ with default config
Contributed by Graham Russell
This closes #334

Modified:
    jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java
    jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCaseJUnit.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java?rev=1815881&r1=1815880&r2=1815881&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java Tue Nov 
21 08:00:06 2017
@@ -41,24 +41,27 @@ public abstract class JMeterTestCase {
     // Used by findTestFile
     private static final String filePrefix;
 
-
     /*
      * If not running under AllTests.java, make sure that the properties (and
      * log file) are set up correctly.
-     * 
-     * N.B. In order for this to work correctly, the JUnit test must be started
-     * in the bin directory, and all the JMeter jars (plus any others needed at
-     * run-time) need to be on the classpath.
-     * 
+     *
+     * N.B. This assumes the JUnit test are executed in the
+     * project root, bin directory or one level down, and all the JMeter jars
+     * (plus any others needed at run-time) need to be on the classpath.
      */
     static {
         if (JMeterUtils.getJMeterProperties() == null) {
             String file = "jmeter.properties";
             File f = new File(file);
             if (!f.canRead()) {
-                System.out.println("Can't find " + file + " - trying bin 
directory");
-                file = "bin/" + file;// JMeterUtils assumes Unix-style 
separators
-                filePrefix = "bin/";
+                System.out.println("Can't find " + file + " - trying bin/ and 
../bin");
+                if (!new File("bin/" + file).canRead()) {
+                    // When running tests inside IntelliJ
+                    filePrefix = "../bin/"; // JMeterUtils assumes Unix-style 
separators
+                } else {
+                    filePrefix = "bin/"; // JMeterUtils assumes Unix-style 
separators
+                }
+                file = filePrefix + file;
             } else {
                 filePrefix = "";
             }

Modified: jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCaseJUnit.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCaseJUnit.java?rev=1815881&r1=1815880&r2=1815881&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCaseJUnit.java 
(original)
+++ jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCaseJUnit.java Tue 
Nov 21 08:00:06 2017
@@ -51,19 +51,23 @@ public abstract class JMeterTestCaseJUni
      * If not running under AllTests.java, make sure that the properties (and
      * log file) are set up correctly.
      * 
-     * N.B. In order for this to work correctly, the JUnit test must be started
-     * in the bin directory, and all the JMeter jars (plus any others needed at
-     * run-time) need to be on the classpath.
-     * 
+     * N.B. This assumes the JUnit test are executed in the
+     * project root, bin directory or one level down, and all the JMeter jars
+     * (plus any others needed at run-time) need to be on the classpath.
      */
     static {
         if (JMeterUtils.getJMeterProperties() == null) {
             String file = "jmeter.properties";
             File f = new File(file);
             if (!f.canRead()) {
-                System.out.println("Can't find " + file + " - trying bin 
directory");
-                file = "bin/" + file;// JMeterUtils assumes Unix-style 
separators
-                filePrefix = "bin/";
+                System.out.println("Can't find " + file + " - trying bin/ and 
../bin");
+                if (!new File("bin/" + file).canRead()) {
+                    // When running tests inside IntelliJ
+                    filePrefix = "../bin/"; // JMeterUtils assumes Unix-style 
separators
+                } else {
+                    filePrefix = "bin/"; // JMeterUtils assumes Unix-style 
separators
+                }
+                file = filePrefix + file;
             } else {
                 filePrefix = "";
             }

Modified: jmeter/trunk/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1815881&r1=1815880&r2=1815881&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Tue Nov 21 08:00:06 2017
@@ -184,6 +184,7 @@ Summary
     <li><pr>323</pr>Extracted method and used streams to improve readability. 
Contributed by Graham Russell (graham at ham1.co.uk)</li>
     <li><pr>324</pr> Save backup refactor. Contributed by Graham Russell 
(graham at ham1.co.uk)</li>
     <li><pr>327</pr> Utilising more modern Java, simplifying code and 
formatting code and comments. Contributed by Graham Russell (graham at 
ham1.co.uk)</li>
+    <li><pr>334</pr> Enable running of JUnit tests from within IntelliJ with 
default config. Contributed by Graham Russell (graham at ham1.co.uk)</li>
 </ul>
 
  <!-- =================== Bug fixes =================== -->


Reply via email to