title: Jmeter: Using jmeter Junit Request with variables
body: <p>As I said in the question, is it possible to pass jmeter variables (passed through -J) into a <code>JUnit Request</code> in order that it can be used internally to the junit test?</p>
  
  <p>It sounds feasible as <a href="http://jmeter.apache.org/usermanual/component_reference.html#JUnit_Request" rel="nofollow">the Apache Junit Request docs</a> indicate that:</p>
  
  <blockquote>
    <p>... JMeter currently runs the test methods directly, rather than
    leaving it to JUnit. ...</p>
  </blockquote>
  
  <p>This would indicate that jmeter could control passing parameters but I've found no supporting documentation and there's no obvious mechanism through the JUnit Request sampler config.  </p>
  
  <p><strong>Background</strong></p>
  
  <p>I was hoping to use <code>CSV Data Set Config</code> to load a user pool (as in <a href="http://jmeter-tips.blogspot.co.uk/2010/03/tip-10-how-to-add-authorization-to-test.html" rel="nofollow">Victor Klepikovskiy excellent top tips</a>) and have a randomly obtained user provided to my unit-tests (for use across the thread/ loop). I've found an alternative way of doing what I want (but use my own user pool accessed from within the junit tests). I know you could manage the login through  <code>Http Request</code> too (as above) but we amanage the rest-service calls internally to junit so that they can be run as junit tests as well. I was interested in being as non-intrusive as possible.</p>
  
  <p>A second reason for doing so might be to have a single junit test method but have it parameterised to suit the scenario.</p>
  
  <p><strong>Addendum</strong></p>
  
  <p>For what it's worth, I'm happy with my current alternative approach but still interested in how you might be able to do this for future reference. I'm fairly new to jmeter but expect to see a fair bit more of it. Was also thinking of looking at the pre-processors but not sure how these could interface with the Junit Request.</p>