2 * Copyright 2000-2010 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.testAssistant
;
18 import com
.intellij
.openapi
.application
.PluginPathManager
;
19 import com
.intellij
.psi
.PsiJavaFile
;
20 import com
.intellij
.psi
.PsiMethod
;
21 import com
.intellij
.testFramework
.TestDataPath
;
22 import com
.intellij
.testFramework
.fixtures
.LightCodeInsightFixtureTestCase
;
24 import java
.util
.List
;
29 @TestDataPath("$CONTENT_ROOT/testData/")
30 public class TestDataReferenceCollectorTest
extends LightCodeInsightFixtureTestCase
{
31 public void testDoTestParameters() throws Exception
{
32 final List
<String
> references
= doTest();
33 assertEquals(1, references
.size());
34 assertEquals("doTestParameters.java", references
.get(0));
37 public void testDoFileTest() throws Exception
{
38 final List
<String
> references
= doTest();
39 assertEquals(2, references
.size());
40 assertTrue(references
.contains("before"));
41 assertTrue(references
.contains("after"));
44 public void testReferencesInAnyMethod() throws Exception
{
45 final List
<String
> references
= doTest();
46 assertEquals(1, references
.size());
47 assertEquals("before", references
.get(0));
50 public void testTestNameAsParameter() throws Exception
{
51 final List
<String
> references
= doTest();
52 assertEquals(1, references
.size());
53 assertEquals("beforeTestNameAsParameter", references
.get(0));
56 private List
<String
> doTest() throws Exception
{
57 myFixture
.configureByFile("referenceCollector/" + getTestName(false) + ".java");
58 final PsiMethod theMethod
= ((PsiJavaFile
)myFixture
.getFile()).getClasses()[0].getMethods()[0];
59 return new TestDataReferenceCollector("", theMethod
.getName().substring(4)).collectTestDataReferences(theMethod
);
63 protected String
getBasePath() {
64 return PluginPathManager
.getPluginHomePathRelative("IdeaTestAssistant") + "/testData/";