Just tried 2.0 - found problem with static fields & @BeforeClass

100 views
Skip to first unread message

David Barri

unread,
May 19, 2013, 5:57:12 PM5/19/13
to robol...@googlegroups.com
Hi,

So I just tried Robolectric 2.0 and I'm seeing an issue.
If I set static fields in a @BeforeClass method, the fields are null by the time my @Before setup() code is run.

private static String JUST_AN_EXAMPLE;

@BeforeClass
public static void enableTestInjection() {
JUST_AN_EXAMPLE = "It works!";
System.out.println("1: " + JUST_AN_EXAMPLE);
}

@Before
public void setup() throws Exception {
System.out.println("2: " + JUST_AN_EXAMPLE);
}

Running the above, I see this in the console.

1: It works!
WARNING: no system properties value for ro.build.date.utc
2: null

Thanks,
DB
Reply all
Reply to author
Forward
0 new messages