vishaalkapoor commented on a change in pull request #13794: [MXNET-1263] Unit Tests for Java Predictor and Object Detector APIs URL: https://github.com/apache/incubator-mxnet/pull/13794#discussion_r246235866
########## File path: scala-package/infer/src/test/java/org/apache/mxnet/infer/javaapi/ObjectDetectorTest.java ########## @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.mxnet.infer.javaapi; + +import org.apache.mxnet.Layout; +import org.apache.mxnet.javaapi.DType; +import org.apache.mxnet.javaapi.DataDesc; +import org.apache.mxnet.javaapi.NDArray; +import org.apache.mxnet.javaapi.Shape; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.List; + +public class ObjectDetectorTest { + + List<DataDesc> inputDesc; + BufferedImage inputImage; + + List<List<ObjectDetectorOutput>> result; + + ObjectDetector objectDetector; + + @Before + public void setUp() { + + inputDesc = new ArrayList<>(); + inputDesc.add(new DataDesc("", new Shape(new int[]{1, 3, 512, 512}), DType.Float32(), Layout.NCHW())); + inputImage = new BufferedImage(512, 512, BufferedImage.TYPE_INT_RGB); + objectDetector = Mockito.mock(ObjectDetector.class); + result = new ArrayList<>(); + result.add(new ArrayList<ObjectDetectorOutput>()); + result.get(0).add(new ObjectDetectorOutput("simbaa", new float[]{})); + } + + @Test + public void testObjectDetectorWithInputImage() { + + Mockito.when(objectDetector.imageObjectDetect(inputImage, 5)).thenReturn(result); + List<List<ObjectDetectorOutput>> actualResult = objectDetector.imageObjectDetect(inputImage, 5); Review comment: Nice! for the integration test. Though this integration test has a different purpose of coverage. For example, it won't cover each of the methods you have. And the current Mock tests in isolation leave a gap between the tests. Ideally there would be more coverage in the unit tests as they are not in the form to catch the most common kind of bug that will be introduced, and that is unexpected input of the same shape - because you're prescribing that input with Mockito. But I don't think I can block as there are integration tests and reasonable unit tests. LGTM. Thanks for making those changes! ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
