Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGregorio Massara
3,544 PointsHow to add import statements for the outside class: SocialNetworkTest
Hello, any clues on how to add a simple import statement for the above class? So I can compile it? Thanks
import java.lang.reflect.Method;
import SocialNetworkTest.java;
public class TestAnalyzer {
/**
* Counts the number of methods in the class given by `clazz` that have been annotated
* with the @Test annotation.
*/
public static int getNumAnnotatedMethods(Class<?> clazz) {
clazz = SocialNetworkTest.class;
Method[] methods = clazz.getDeclaredMethods();
int counter = 0;
for (Method m : methods) {
if (m.isAnnotationPresent(Test.class)) {
counter++;
}
}
return counter;
}
}
1 Answer
Gregorio Massara
3,544 Points.....got the error: I was instantiating again the SocialNetworkTest.class, got rid of java clazz = SocialNetworkTest.class; and the test passed.
Gregorio Massara
3,544 PointsGregorio Massara
3,544 Points.....got the error: I was instantiating again the SocialNetworkTest.class, got rid of
java clazz = SocialNetworkTest.class;
and the test passed.