Tagged articles
JUnit
63 articles · Page 1 of 1
This tutorial demonstrates how to configure MyBatis SQL statements using Java annotations instead of XML, covering Maven dependencies, project structure, core configuration files, entity mapping, dynamic SQL providers, mapper interfaces with @Select/@Insert/@Update/@Delete annotations, service layer implementation, and JUnit testing.
AnnotationsDynamic SQLJUnit
0 likes · 17 min read

This tutorial demonstrates setting up Redis on Windows, configuring a Maven project with Jedis 4.1.1, building a connection pool utility, and providing JUnit test examples for operating Redis Strings, Lists, Hashes, Sets, and Sorted Sets with Jedis API.
JUnitJavaJedis
0 likes · 13 min read

This tutorial demonstrates how to integrate Spring with MyBatis and JUnit using only annotations, covering Maven dependencies, Druid data source configuration, MyBatis SqlSessionFactory setup, mapper scanning, dynamic SQL with @SelectProvider, service layer wiring, and JUnit test execution with Spring's test context framework.
Annotation ConfigurationDruidDynamic SQL
0 likes · 22 min read

This tutorial demonstrates how to implement Spring declarative transaction management using only annotations, covering project setup, configuration classes, MyBatis integration, service layer @Transactional usage, and JUnit tests verifying commit and rollback behavior.
@EnableTransactionManagementAnnotationsDataSourceTransactionManager
0 likes · 15 min read

This tutorial demonstrates Spring's JdbcTemplate and NamedParameterJdbcTemplate for database CRUD operations, covering Maven setup, Druid connection pooling, configuration classes, DAO implementations with both positional and named parameters, service layer, and JUnit tests, recommending NamedParameterJdbcTemplate for production use.
BeanPropertyRowMapperDruidJDBC
0 likes · 21 min read

The article introduces JUnit's @AutoClose annotation (added in version 5.11), compares the traditional @BeforeEach/@AfterEach cleanup pattern with the annotation's automatic resource closing, and demonstrates its use across file I/O, database connections, HTTP clients, streams, and custom AutoCloseable classes, including warning behavior for null fields.
@AutoCloseJUnitJUnit5
0 likes · 8 min read

This comprehensive tutorial explains JUnit's definition, core components, annotations, assertion methods, test suite creation, custom test rules, and how common design patterns such as Factory, Decorator, Strategy, and Template Method can be applied to write flexible, maintainable Java unit tests, plus installation steps and advanced usage tips.
JUnitJavaTest Annotations
0 likes · 25 min read

This article walks through adjusting Java unit tests with ChatGPT, measuring coverage using JaCoCo, rewriting test code for User and PasswordRecovery classes, adding Mockito and PowerMock mocks, and showing how the changes raise coverage from 73.7% to over 80% across the project.
ChatGPTJUnitJaCoCo
0 likes · 17 min read

The article explains how Spring Boot’s @Sql annotation lets you declaratively run SQL scripts before or after test methods to set up or clean up test data, covering placement, default behavior, configuration options, execution timing, transaction handling, and common pitfalls.
JUnitJavaSQL
0 likes · 7 min read

This article presents a comprehensive guide to testing Spring Boot controller layers, covering isolated @WebMvcTest, full‑stack @SpringBootTest, WebTestClient, TestRestTemplate, standalone MockMvc, REST Assured, exception‑handling advice, and pure Mockito unit tests, each with purpose, core annotations, sample code, pros, cons, and usage recommendations.
Controller TestingIntegration TestJUnit
0 likes · 20 min read

Fuzz testing injects massive amounts of random or semi‑random inputs into applications to expose crashes, logic errors, and security flaws, and the article explains its principles, the types of defects it uncovers, real‑world practices at Google Chrome, and step‑by‑step Java integration using CI Fuzz and JUnit.
CI FuzzDynamic AnalysisJUnit
0 likes · 7 min read

This article compares Java string concatenation using the '+' operator versus StringBuilder, showing that for simple cases '+' is equally fast and more concise, while in loops StringBuilder dramatically outperforms '+' due to reduced object creation overhead.
JUnitString ConcatenationStringBuilder
0 likes · 8 min read

This article investigates the performance differences between Java’s ‘+’ operator, StringBuilder, and StringJoiner for string concatenation, presenting JUnit benchmark results for single and looped concatenations, analyzing compiled bytecode, and concluding when each method is optimal for readability and speed.
JUnitString ConcatenationStringBuilder
0 likes · 7 min read

This article demonstrates how to use the H2 database with Java 1.8, covering embedded (file and memory) modes, server modes (Web, TCP, PG), mixed mode configurations, required dependencies, and provides complete JUnit test code examples for creating, accessing, and managing tables.
EmbeddedJDBCJUnit
0 likes · 17 min read

This article presents a detailed, step‑by‑step guide on improving unit test coverage in large Java codebases, covering strategies such as mocking, divide‑and‑conquer, tool‑assisted test generation, reflection‑based coverage, Maven configuration, and practical tips for handling static methods, final classes, and test data replay.
JUnitJavaMockito
0 likes · 27 min read

This guide explains what unit testing is, its benefits, the AIR principles of good tests, step‑by‑step Java test creation with JUnit and Mockito, and how the AI tool Tongyi Lingma can quickly generate reliable unit tests.
JUnitJavaMockito
0 likes · 12 min read

The article demonstrates how PowerMock can be used to unit‑test a Java FileParser class—showing basic mocks for files and streams, advanced techniques for final and static classes, and achieving full coverage—while warning that its heavy class‑loader overhead can dramatically slow large test suites and increase memory consumption.
JUnitJavaMocking
0 likes · 10 min read

This article explains idempotency testing, outlines common scenarios such as network requests and financial transactions, describes methods to detect duplicate requests, provides comprehensive coverage strategies, offers practical test‑case examples, lists relevant testing tools, and includes a JUnit code sample for implementation.
IdempotencyJUnitsoftware testing
0 likes · 11 min read

This article examines Java string concatenation performance by comparing the '+' operator and StringBuilder in both simple and loop scenarios, presenting JUnit test results, bytecode analysis, and practical recommendations for choosing the most efficient approach.
JUnitJavaString Concatenation
0 likes · 6 min read

This article examines the performance differences between using the '+' operator and StringBuilder for string concatenation in Java, presenting JUnit benchmark tests for simple concatenations and looped concatenations, analyzing compiled bytecode, and concluding that '+' is suitable for simple cases while StringBuilder excels in loops.
JUnitJavaString Concatenation
0 likes · 7 min read

This tutorial shows Java engineers how to build a JUnit Rule that captures test failures, extracts the exception stack and source file, and automatically sends the information to OpenAI's GPT for analysis and code‑fix suggestions, complete with reusable data‑model classes and utility methods.
AIGPTJUnit
0 likes · 13 min read

This tutorial teaches Java engineers how to build a JUnit4 Rule that captures test failures, extracts stack traces and source files, sends them to GPT for automated analysis, and logs the AI‑generated code improvement suggestions, complete with full example code and usage.
AI integrationGPTJUnit
0 likes · 13 min read

This article presents a concise, beginner-friendly approach to building a Spring Boot unit testing environment using only essential Maven dependencies and test classes, covering both integration-style and pure unit test techniques, complete with annotated examples and practical testing tips.
Integration TestJUnitJava
0 likes · 9 min read

This article explains the core concepts of the Mockito framework, compares it with other Java unit‑testing tools, demonstrates practical code examples, and breaks down the internal workings of annotations like @InjectMocks, @Mock, @RunWith, as well as the Mockito.when() and Mockito.verify() mechanisms.
AnnotationsJUnitMocking
0 likes · 22 min read

This article examines Java string concatenation methods, presenting JUnit benchmarks that compare the '+' operator and StringBuilder in both single and loop scenarios, revealing that while simple concatenations perform similarly, loop concatenations are dramatically faster with StringBuilder, leading to practical recommendations.
BackendJUnitStringBuilder
0 likes · 8 min read


IT NiukeDec 27, 2023 · Backend Development
The article investigates IntelliJ IDEA's suggestion to replace StringBuilder with the '+' operator, showing that for simple concatenations the compiled code is identical and performance comparable, while in loops '+' becomes inefficient and StringBuilder remains preferable.
IntelliJ IDEAJUnitJava
0 likes · 8 min read

An empirical study compares Java string concatenation using the '+' operator versus StringBuilder, showing that for simple concatenations '+' is equally efficient and more concise, while in loops '+' incurs significant overhead, making StringBuilder the preferred choice for iterative concatenation.
JUnitJavaString Concatenation
0 likes · 6 min read

This article explains what unit testing is, why it’s essential, and provides a step‑by‑step guide for writing Java unit tests with JUnit, integrating them into Maven projects, and generating detailed coverage reports using IDE features and JaCoCo.
JUnitJaCoCoJava
0 likes · 16 min read

This article explores Test‑Driven Development (TDD), explaining its core concepts, common misconceptions, tool choices such as JUnit, Mockito and JaCoCo, and provides practical case studies including a simple calculator and layered architecture examples in both anemic and DDD models.
DDDJUnitJaCoCo
0 likes · 28 min read

This article demonstrates how to use JUnit's Assert methods for various checks, creates mock objects and verifies interactions with Mockito, and leverages Java 8 Stream's peek operation for debugging, providing complete code examples for each technique.
JUnitJavaJava8
0 likes · 14 min read

The Taobao User Operations Platform team reduced CI unit‑test time from fifty minutes to ten by configuring Maven Surefire to reuse forks, use a fork count of twice the CPU cores, and run methods in parallel with an appropriate thread count, achieving faster builds while keeping failure rates low.
CIJUnitJava
0 likes · 10 min read

This article explains why JUnit is a popular Java testing framework, lists its key features, and provides a comprehensive guide to using JUnit annotations—including @BeforeClass, @Before, @Test, @After, @AfterClass, @Ignore, and advanced annotations—in Selenium WebDriver automation scripts, complete with code examples and execution order details.
AnnotationsJUnitJava
0 likes · 11 min read

This article explains unit testing concepts, outlines the differences between TestNG and JUnit—including test suite configuration, annotations, grouping, parameterization, dependency handling, exception and timeout testing—and provides code examples to help developers choose the most suitable Java testing framework.
AnnotationsJUnitJava
0 likes · 11 min read

This article provides a comprehensive guide to JUnit runners, detailing the purpose and usage of Suite, Theories, Categories, Enclosed, Parameterized, IgnoredClassRunner and other executors, accompanied by code examples and execution results to help developers apply flexible unit testing strategies in Java projects.
JUnitJavaRunner
0 likes · 12 min read


JD TechMay 25, 2022 · Backend Development
This article explains the purpose and usage of various JUnit runners—including Suite, RunWith, BlockJUnit4ClassRunner, ParentRunner, Theories, Categories, Enclosed, Parameterized, and error‑handling runners—providing code examples and practical insights for flexible unit testing in Java projects.
JUnitTest Automationparameterized tests
0 likes · 12 min read

The article walks through a step‑by‑step evolution of a simple isEmpty utility, demonstrates proper JUnit assertions, introduces Mockito for isolating complex service logic, and explains Spring Boot Test components, illustrating why thorough unit testing saves time and improves code quality.
JUnitJavaMockito
0 likes · 13 min read

This article surveys the popularity of Java, outlines the benefits of using Java testing frameworks, and provides detailed overviews of nine leading frameworks—including JUnit, JBehave, Serenity, Selenium, TestNG, Mockito, HTTPUnit, Gauge, and Geb—highlighting their core features and suitability for different testing needs.
FrameworksJUnitJava
0 likes · 18 min read

This comprehensive guide walks you through writing effective Java unit tests, covering test framework basics, Maven dependencies, typical code examples, step‑by‑step test case creation, mocking techniques with Mockito and PowerMock, verification strategies, handling special cases, and best practices for achieving high coverage.
JUnitJavaMocking
0 likes · 48 min read

This article explains the fundamentals of unit testing in Spring Boot, covering the purpose of unit tests, how to add the spring-boot-starter-test dependency, the role of MockMvc for controller testing, step‑by‑step creation of Service and Controller test classes, key annotations, assertion techniques, and a brief comparison with Postman.
JUnitJavaMockMvc
0 likes · 13 min read

This article explains what unit testing is, why it’s essential, common obstacles, best practices for writing effective Java unit tests, including naming conventions, assertions, mocking strategies, and design principles for testable code.
JUnitJavaMockito
0 likes · 10 min read

This article introduces mock testing for Spring MVC controllers, explains why mocks are useful, describes the main MockMvc components, shows required Maven dependencies, and provides complete example test cases for both view‑returning and JSON‑returning endpoints using JUnit and MockMvc.
BackendJUnitJava
0 likes · 8 min read

This article explains how to integrate JUnit unit testing into Jenkins pipelines using Maven and Spring Boot, covering project setup, dependency configuration, test case creation, Jenkins job configuration, and result reporting to achieve fully automated testing in a DevOps workflow.
CI/CDDevOpsJUnit
0 likes · 6 min read

This article explains how automation testers can use JUnit parameterized testing with Selenium to avoid repetitive test scripts, covering annotation‑based and Excel‑driven data sources, and provides complete Java code examples for both approaches.
ExcelJUnitparameterized-testing
0 likes · 11 min read

This article explains what makes good code, introduces SOLID and other design principles, defines unit testing, outlines its benefits, provides before‑and‑after Java refactoring examples, and reviews essential testing tools like Fast‑tester, JUnit and Mockito along with coverage metrics.
Design PrinciplesJUnitJava
0 likes · 19 min read

The guide walks developers through Android testing basics by explaining JUnit unit tests, instrumented tests, and Espresso UI tests, showing where local and device tests reside, demonstrating how to generate a Calculator unit test and an Espresso test for a simple activity, and how to run them in Android Studio.
AndroidEspressoJUnit
0 likes · 12 min read

This guide walks through setting up a Windows environment with TestLink, Jenkins, and Eclipse, adding JUnit support, configuring TestLink custom fields, and creating a Jenkins freestyle job that runs Ant builds, invokes TestLink, and publishes JUnit test results for seamless automated reporting.
CI/CDJUnitJenkins
0 likes · 9 min read

This article explains how to use Mockito's doNothing, doAnswer, doThrow, and doCallRealMethod to mock void methods in Java, demonstrating parameter verification, argument capture, and real‑method invocation with detailed code examples and reasoning behind each approach.
JUnitJavaMocking
0 likes · 6 min read


转转QAJun 24, 2020 · Fundamentals
This article introduces EvoSuite, an open‑source tool for automatically generating JUnit test suites, explains how to configure it with Maven (including the required pom.xml entries), describes essential command‑line options, and provides step‑by‑step instructions for installing and using the EvoSuite plugin in IntelliJ IDEA, supplemented by practical examples and coverage analysis.
EvoSuiteIntelliJ IDEAJUnit
0 likes · 7 min read

This guide explains why unit testing matters, compares Java testing tools, introduces PowerMock’s capabilities, details essential annotations, shows how to configure dependencies, and provides step‑by‑step code examples for mocking public, final, static, private, constructor, field and superclass methods.
JUnitJavaMocking
0 likes · 10 min read

This article outlines the essential steps for creating a traditional Java web application, covering environment preparation, Maven skeleton creation, required dependencies for logging, databases, persistence, Spring integration, DAO and service layers, unit testing, and RESTful controller configuration.
JUnitJavaMaven
0 likes · 10 min read


ITPUBJan 8, 2020 · Backend Development
This guide shows how to test asynchronous email‑sending logic in a Spring Boot application using Byteman, the BMUnit extension, JUnit 4, and a join‑er mechanism, all without modifying production code.
BytemanJUnitasync-testing
0 likes · 12 min read

This article explains how test‑coverage metrics such as line and branch coverage can give a false sense of quality, demonstrates common pitfalls with Java examples and Cobertura reports, and offers practical guidelines for using coverage data to improve testing and code reliability.
CoberturaJUnitJava
0 likes · 17 min read

This article compares four popular Java testing frameworks—JUnit, JBehave, Selenide, and Spock—examining their prerequisites, strengths, weaknesses, and ideal use cases when integrated with Selenium WebDriver for UI and BDD testing.
JBehaveJUnitJava
0 likes · 13 min read

This article explains the fundamentals of unit testing in Java, covering what unit tests are, why they matter, when to write them, and detailed step‑by‑step examples using Mockito, PowerMock, JUnit, and Spring Boot to mock dependencies, verify behavior, and assert results across DAO, service, and controller layers.
JUnitMockingMockito
0 likes · 28 min read

The article explains why many developers avoid unit testing despite its importance, demonstrates a Java method for filtering unpromised tools in a home‑renovation app, provides complete JUnit and Groovy/Spock test implementations, and shows how richer output from Groovy/Spock can speed debugging.
GroovyJUnitJava
0 likes · 10 min read

This tutorial walks through writing and running unit and integration tests for a Spring Boot application, covering JUnit and Hamcrest assertions, Maven setup, model definitions, service and controller implementations, MockMvc usage, and both mocked and real‑world test scenarios, complete with sample code and output.
HamcrestIntegration TestJUnit
0 likes · 25 min read

This article introduces JUnit 5, explains its architecture and key features, and provides step‑by‑step examples of writing, configuring, and running unit tests in Java, covering annotations, lifecycle methods, disabled tests, nested tests, repeated tests, assertions, timeout checks, exception handling, and parameterized testing.
JUnitJUnit 5Java unit testing
0 likes · 17 min read

This tutorial explains how to use Spring Boot's ApplicationContextRunner to simplify testing of auto‑configuration classes, covering class, bean, and property conditions with concrete code examples and assertions for both present and missing scenarios.
ApplicationContextRunnerAuto-configurationJUnit
0 likes · 8 min read

Spring Boot determines the main application class by creating a RuntimeException, inspecting its stack trace for a method named 'main', and loading the corresponding class via Class.forName, a process illustrated with source code and a JUnit test that compares printed stack traces to the thrown exception.
JUnitJavaMainClassDetection
0 likes · 7 min read


转转QAApr 3, 2019 · Operations
This article explains how to design and extend a UI automation testing framework using Selenium 2.0 and JUnit 4, covering control identification and encapsulation, test case organization and execution, as well as custom logging and reporting to improve maintainability and efficiency.
JUnitTesting FrameworkUI automation
0 likes · 6 min read

This article explains the shortcomings of traditional distributed microservice testing, introduces consumer‑driven contract testing, outlines the evolution of a distributed R&D model, and provides a step‑by‑step guide with code samples for implementing Spring Cloud Contract in both provider and consumer services.
Consumer-Driven ContractsJUnitJava
0 likes · 13 min read

The article introduces Google’s Espresso framework for Android UI automation, explains how to configure Gradle dependencies and the test runner, and guides developers through writing robust test cases by locating views, performing actions, and asserting states with onView().perform().check(), including a complete @Rule‑based example.
AndroidAndroid StudioEspresso
0 likes · 8 min read

The article examines common pitfalls when retrieving a day's orders in MySQL, explains why using BETWEEN can be ambiguous, shows how timestamp precision and appending .999 affect results, and argues for clear, maintainable SQL and test‑code practices.
BETWEENJUnitcode-quality
0 likes · 8 min read
