[infer][eradicate] Consider junit.framework.TestCase.setUp as an initializer

Summary: The method `junit.framework.TestCase.setUp()` is always run before the other methods by the JUnit testing framework. So the method act as a class initializer.

Reviewed By: sblackshear

Differential Revision: D4487371

fbshipit-source-id: 1998801
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent 90f4c83ef2
commit b6fae5cd46

@ -258,6 +258,7 @@ let initializer_classes =
"android.app.Fragment";
"android.app.Service";
"android.support.v4.app.Fragment";
"junit.framework.TestCase";
]
let initializer_methods = [
@ -265,6 +266,7 @@ let initializer_methods = [
"onAttach";
"onCreate";
"onCreateView";
"setUp";
]
(** Check if the type has in its supertypes from the initializer_classes list. *)

@ -0,0 +1,25 @@
/*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import junit.framework.TestCase;
public class JunitExample extends TestCase {
private Object mField;
@Override
protected void setUp() throws Exception {
super.setUp();
mField = new Object();
}
public void testSomething() {
mField.toString();
}
}

@ -17,5 +17,6 @@ GUAVA = $(DEPENDENCIES_DIR)/java/guava/guava-10.0.1-fork.jar
JACKSON = $(DEPENDENCIES_DIR)/java/jackson/jackson-2.2.3.jar
JSR305 = $(DEPENDENCIES_DIR)/java/jsr-305/jsr305.jar
INJECT = $(DEPENDENCIES_DIR)/java/jsr-330/javax.inject.jar
JUNIT = $(DEPENDENCIES_DIR)/java/junit/junit-4.11.jar
CLASSPATH=$(ANDROID):$(ANDROIDSUPPORT):$(ANNOTATIONS):$(BUTTERKNIFE):$(GUAVA):$(JACKSON):$(JSR305):$(INJECT):$(JAVA_BUILTINS_DIR):.
CLASSPATH=$(ANDROID):$(ANDROIDSUPPORT):$(ANNOTATIONS):$(BUTTERKNIFE):$(GUAVA):$(JACKSON):$(JSR305):$(INJECT):$(JAVA_BUILTINS_DIR):$(JUNIT):.

Loading…
Cancel
Save