Back to Repositories

Validating Plugin Version Extraction Functionality in JADX

This test suite validates the version extraction functionality in the JADX plugin utilities. It ensures proper parsing of version numbers from plugin filenames through targeted unit tests using JUnit and AssertJ assertions.

Test Coverage Overview

The test coverage focuses on the extractVersion utility method, validating different version number formats in plugin filenames.

Key functionality tested:
  • Standard three-segment version (v1.2.3)
  • Two-segment version format (v1.2)
  • Version without ‘v’ prefix
Edge cases include varying filename patterns and version number lengths.

Implementation Analysis

The testing approach employs JUnit Jupiter with AssertJ assertions for robust version string validation. The implementation uses a single test method with multiple assertions to verify different version extraction scenarios.

Testing patterns include:
  • Fluent assertion syntax with AssertJ
  • Multiple test cases in single method
  • Static import optimization

Technical Details

Testing tools and configuration:
  • JUnit Jupiter test framework
  • AssertJ assertion library
  • Static imports for clean test syntax
  • Java package structure: jadx.plugins.tools.utils

Best Practices Demonstrated

The test suite demonstrates clean testing practices with focused assertions and clear test cases. Notable practices include:
  • Descriptive test method naming
  • Efficient test case organization
  • Clear assertion statements
  • Consistent version string validation

skylot/jadx

jadx-cli/src/test/java/jadx/plugins/tools/utils/PluginUtilsTest.java

            
package jadx.plugins.tools.utils;

import org.junit.jupiter.api.Test;

import static jadx.plugins.tools.utils.PluginUtils.extractVersion;
import static org.assertj.core.api.Assertions.assertThat;

class PluginUtilsTest {

	@Test
	public void testExtractVersion() {
		assertThat(extractVersion("plugin-name-v1.2.3.jar")).isEqualTo("1.2.3");
		assertThat(extractVersion("plugin-name-v1.2.jar")).isEqualTo("1.2");
		assertThat(extractVersion("1.2.3.jar")).isEqualTo("1.2.3");
	}

}