squaretest

Open full view…

Why is there so little test code generated?

xxshang
Thu, 12 Nov 2020 06:56:59 GMT

Hi, For example, my class code is as follows: import android.graphics.drawable.Drawable; public class AboutInfo { private Drawable appIcon; private String appName; private String version; private String packageName; private boolean isFawApp; public AboutInfo() { } public AboutInfo(Drawable appIcon, String appName, String version, String packageName, boolean isFawApp) { this.appIcon = appIcon; this.appName = appName; this.version = version; this.packageName = packageName; this.isFawApp = isFawApp; } public Drawable getAppIcon() { return appIcon; } public void setAppIcon(Drawable appIcon) { this.appIcon = appIcon; } public String getName() { return appName; } public void setAppName(String appName) { this.appName = appName; } public String getVersion() { return version; } public void setVersion(String version) { this.version = version; } public void setPackageName(String packageName) { this.packageName = packageName; } public String getPackageName() { return packageName; } public boolean isFawApp() { return isFawApp; } public void setFawApp(boolean fawApp) { isFawApp = fawApp; } } The generated test case code is as follows: package com.ticauto.settings.bean; import android.graphics.drawable.Drawable; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import static org.junit.Assert.assertEquals; import static org.mockito.MockitoAnnotations.initMocks; public class AboutInfoTest { @Mock private Drawable mockAppIcon; private String appName; private String version; private String packageName; private boolean isFawApp; private AboutInfo aboutInfoUnderTest; @Before public void setUp() { initMocks(this); appName = "appName"; version = "version"; packageName = "packageName"; isFawApp = false; aboutInfoUnderTest = new AboutInfo(mockAppIcon, appName, version, packageName, isFawApp); } @Test public void testGetName() { // Setup // Run the test final String result = aboutInfoUnderTest.getName(); // Verify the results assertEquals("result", result); } } I want to know if this is normal? Why is there so little test case code generated? Doesn't every method generate a test method?

nate-squaretest
Thu, 28 Sep 2023 21:52:58 GMT

Thank you for reaching out. I apologize for the delayed response. Squaretest has improved significantly since this post. It now supports generating tests for getters and setters as well as other options. To create tests for getter/setter methods, please choose *Alt+Insert | Generate Test Confirm Options*. Then select the methods to test. The Squaretest forum is moving to GitHub Discussions. Please use https://github.com/SquaretestLLC/Squaretest/discussions for any future forum posts.