title: Create a dictionary and pass it as a map to a Java method in Robot Framework
body: <p>I need to pass a java.util.Map to a a test method
  In the tsv file, I tried to create a dictionary like this:</p>
  
  <pre><code>${MYDICT} =  Create Dictionary  a  1  b  2
  </code></pre>
  
  <p>But I got the error:</p>
  
  <blockquote>
    <p>Setting variable '${MYDICT} = Create Dictionary a 1 b 2' failed: Variable name '${MYDICT} = Create Dictionary a 1 b 2' is invalid.</p>
  </blockquote>
  
  <p>I declare the dictionary in the variables section like this:</p>
  
  <pre><code>    ${MYDICT}=  Create Dictionary   COUNTRY US  CURRENCY_CODE   USD
  </code></pre>
  
  <p>the test case is this:</p>
  
  <pre><code>    testCase1 run the test using ${MYDICT}
  </code></pre>
  
  <p>and the test keywords are defined like this:</p>
  
  <pre><code>    run the test using ${MAP}
          call java method ${MAP}
  </code></pre>
  
  <p>and the Java method is:</p>
  
  <pre><code>    public void CallJavaMethod(Map&lt;String, String&gt; map)
  </code></pre>
  
  <p>However, if I declare the dictionary in the Test keywords section, everything works fine and the Java method is called:</p>
  
  <pre><code>    run the test using
          ${MYDICT}=  Create Dictionary   COUNTRY US  CURRENCY_CODE   USD
          call java method ${MYDICT}
  </code></pre>
  
  <p>I do not understand why I must declare the dictionary at the point where I want to use it. What if I want to run that test case with different inputs?</p>
  
  <p><strong>Fix</strong> ( used what @Uri and @Brian suggested)
  I try to use the "Set Suite Variable" like in this example:</p>
  
  <pre><code>*** Settings ***
  Library Collections
  Suite Setup Initialize dictionary
  
  *** Keywords ***
  Initialize dictionary
      ${dict}=    Create Dictionary   COUNTRY US
      Set Suite Variable  ${dict}
  
  *** Test cases ***
  testDict
      Dictionary should contain item  ${dict} COUNTRY US
  </code></pre>
  
  <p>And the test passes successfully.</p>