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 trialChance Edward
4,507 PointsPutting it all together (Can anyone give me the answer to this question.)
Apply the @Test annotation to exactly three methods of the SocialNetworkTest class, specifying values for both elements in each of the three annotations (that is, don't rely on the element defaults).
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface Test {
int num() default 1;
boolean enabled() default true;
}
import java.lang.annotation.*;
public class SocialNetworkTest {
@Test(num = 3, enabled = false)
public void testTweet() {
}
@Test(num = 1, enabled = false)
public void testInsta() {
}
@Test(num = 2, enabled = false)
public void testFacebook() {
}
public void testPinterest() {
}
public void testSnapchat() {
}
}
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) {
return 0;
}
}
1 Answer
Rohald van Merode
Treehouse StaffHey Chance Edward 👋
I just tried pasting your code in the challenge and once I hit the 3rd task I'm getting the following error:
Bummer: It appears that at least one of your annotations either omits one of your defined elements in the @Test annotation or has used the same value as the default.
On your second @Test
you're setting num
to be 1
which is the default you've set in Test.java
on line 6.
Simply change the value of num
in that second @Test
instance and your code should pass the challenge as expected.
Hope this helps!