diff --git a/infer/src/checkers/patternMatch.ml b/infer/src/checkers/patternMatch.ml index d0c07ffdf..77b7d7efc 100644 --- a/infer/src/checkers/patternMatch.ml +++ b/infer/src/checkers/patternMatch.ml @@ -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. *) diff --git a/infer/tests/codetoanalyze/java/eradicate/JunitExample.java b/infer/tests/codetoanalyze/java/eradicate/JunitExample.java new file mode 100644 index 000000000..86e974786 --- /dev/null +++ b/infer/tests/codetoanalyze/java/eradicate/JunitExample.java @@ -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(); + } + +} diff --git a/infer/tests/java.make b/infer/tests/java.make index 7b695ad84..d0c36e5a6 100644 --- a/infer/tests/java.make +++ b/infer/tests/java.make @@ -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):.