11

How can I access two classes with the same name in different packages?

foo.bar.myClass.class

and

foo.myClass.class

All of this in the same class

@TestRunner(Suite.class)
@SuiteTest({bar.myClass.class, myClass.class})

Thank you.

Drahakar
  • 5,986
  • 6
  • 43
  • 58

3 Answers3

16

you will have to import one and other you will be writting fully qualified path

for example in your code:

import foo.bar.myClass;

.
.
.
myClass ob; // this  will refer to foo.bar.myClass 
foo.myClass ob1 ;//this  will refer to foo.myClass
jmj
  • 237,923
  • 42
  • 401
  • 438
  • @Drahakar Why reverted back it as answer ? let us know if you want more info so that we can help more – jmj Dec 06 '10 at 16:34
4

You need to use the fully qualified names of the classes.

 foo.bar.myClass myvar;
 foo.myClass anothervar;
Vincent Ramdhanie
  • 102,349
  • 23
  • 137
  • 192
0

Without imports:

@TestRunner(Suite.class)
@SuiteTest({foo.bar.myClass.class, foo.myClass.class})
Boris Pavlović
  • 63,078
  • 28
  • 122
  • 148