Increase unit test coverage with JaCoCo report, 845+ tests, math bug fixes, and scenegraph behavior coverage#2638
Increase unit test coverage with JaCoCo report, 845+ tests, math bug fixes, and scenegraph behavior coverage#2638
Conversation
Co-authored-by: riccardobl <4943530+riccardobl@users.noreply.github.com>
|
this is a good start @copilot but we need more 99x more unit tests and you didn't add the jacoco report to the gradle build script |
…, audio, and util classes Co-authored-by: riccardobl <4943530+riccardobl@users.noreply.github.com>
Add complex behavioral tests covering logic correctness, invariants, edge cases, and cross-method consistency for: - Matrix3fTest: near-singular invertLocal regression, adjoint identity, rotation matrix orthogonality (R^-1 == R^T), mult associativity/ non-commutativity, angle-axis rotations, scale inverse reciprocal, float-array round-trip (11 new tests) - Matrix4fTest: near-singular invert/invertLocal regressions, translation composition, homogeneous vector transform, rotation composition, scale matrix, affine inverse round-trip (9 new tests) - QuaternionTest: identity, angle-axis round-trip, norm (squared), normalizeLocal, multiply identity/inverse, conjugate anti-homomorphism, fromAngles round-trip, slerp at 0/0.5/1, rotation matrix round-trip, rotateVector, mult associativity, add/subtract (15 new tests) - Vector2fTest: dot geometry, cross z-component, normalize unit/direction, length == distance, angle between, interpolateLocal at 0/0.5/1, add-subtract round-trip, mult-divide inverse (11 new tests) - Vector4fTest: dot geometry, normalize unit, projection idempotency, projection onto self, scaleAdd (2-arg and 3-arg), minLocal/maxLocal, add-subtract round-trip, negateLocal twice (9 new tests) - PlaneTest: reflect preserves distance, reflect point on plane, setPlanePoints all on plane, getClosestPoint on plane / minimises distance, non-axis-aligned plane (6 new tests) - RayTest: parallel-to-triangle no hit, behind-origin no hit, distanceSquared point on ray, perpendicular distance, vertex edge case (5 new tests) - LineSegmentTest: distance to self, parallel segments, perpendicular segments, positive/negative end vector identity, isPointInsideBounds with error, distanceSquared at negative end (6 new tests) - EasingTest: linear/inQuad monotonicity, outBounce boundary values, inOutQuad symmetry, outQuad faster than inQuad early, smoothStep zero derivative at endpoints, custom InOut boundary values (7 new tests) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…r matrix inversion bug Co-authored-by: riccardobl <4943530+riccardobl@users.noreply.github.com>
Done! This PR now has 845 New test files added:
JaCoCo: added to Bug fixes discovered during testing (commits
All three are now fixed to use Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot extend the coverage to the scenegraph |
…eneGraphIterator Co-authored-by: riccardobl <4943530+riccardobl@users.noreply.github.com>
Extended coverage into scenegraph in commit Added two new behavior-focused test classes:
No UI changes in this PR (test-only changes). Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Significantly expands unit test coverage across the engine, adds a JaCoCo coverage report to the Gradle build, and fixes three bugs discovered during testing.
JaCoCo Coverage Report
Added
apply plugin: 'jacoco'and ajacocoTestReporttask (XML + HTML) tocommon.gradle, so coverage reports are generated for all subprojects after every test run.Bug Fixes
Three inconsistent near-singular matrix checks were found and fixed:
Matrix3f.invertLocal()— used<= 0fwhileMatrix3f.invert()correctly used<= FastMath.FLT_EPSILON. Near-singular matrices (0 < |det| ≤ FLT_EPSILON) produced numerically garbage inverses instead of zeroing out.Matrix4f.invert()— same<= 0fbug; would not throwArithmeticExceptionfor near-zero-determinant matrices.Matrix4f.invertLocal()— same<= 0fbug; would not zero out near-singular matrices.Regression tests covering all three fixes are included.
New Test Classes
Vector2fTest(59 tests) — arithmetic, dot/cross geometry, normalize→unit, length==distance, angle between, interpolation at t=0/0.5/1, add-subtract-multiply-divide round-trips,isValidVector, clone, equals, static constantsVector4fTest(50 tests) — same arithmetic coverage plusscaleAdd, projection idempotency,minLocal/maxLocal,isUnitVector, negateLocal round-tripMatrix3fTest(47 tests) — constructors, identity/zero,absoluteLocal, determinant, transpose round-trip, invert (singular → all-zeros, near-singular regression, product = identity), R⁻¹=Rᵀ for rotation matrices, M·adj(M)=det·I, mult associativity/non-commutativity,fromAngleAxis, float array round-tripsMatrix4fTest(38 tests) — same matrix coverage plusadd/addLocal, translation composition,setTranslation/toTranslationVector, near-singular regression, affine inverse round-trip,mult(Vector3f)andmult(Vector4f), rotation composition,fromAngleAxisQuaternionTest(15 tests) — identity, norm (squared),normalizeLocal, angle-axis round-trip, multiply×identity, multiply×inverse, conjugate anti-homomorphism(q·p)⁻¹=p⁻¹·q⁻¹,fromAnglesround-trip, slerp at t=0/0.5/1, rotation matrix conversion, vector rotation, mult associativity, add/subtractPlaneTest(23 tests) — pseudoDistance,whichSide,isOnPlane, reflect preserves distance, reflect point-on-plane=identity,setPlanePointsall three points on plane,getClosestPointon plane and minimises distance, non-axis-aligned plane normalRayTest(16 tests) — constructors, distance, triangle intersection (hit/miss), parallel-to-triangle miss, behind-origin miss, zero distance for point-on-ray, vertex edge caseLineSegmentTest(19 tests) — constructors, endpoints, distance to self=0, parallel/perpendicular segment distances,isPointInsideBoundswith tolerance, distanceSquared at endpointsEasingTest(26 tests) — all built-in easing functions, monotonicity, inOutQuad symmetry f(1−t)=1−f(t), smoothStep zero derivative at endpoints, customInOutboundary valuesLightTest—DirectionalLight,PointLight,AmbientLight,SpotLightconstructors, setters, clone,toStringListenerTest— audioListenerposition/velocity/rotation/volume, copy constructor, direction vectorsSafeArrayListTest— add/get/set/remove/clear, iterator safety,containsAll,addAll,removeAll,retainAll,subList,cloneIntMapTest— put/get,containsKey/containsValue, remove, clear, overwrite, iterator, clone, large map, negative keysSortUtilTest—gsort,qsort(Object[] and int[]),msort— empty, single-element, already-sorted, reverse, random, duplicatesBufferUtilsTest—createFloatBufferfor all vector/color/quaternion types, Vector2/3/4 set/populate round-trips,getVector3Array/getVector2ArrayScenegraph Coverage Extension
Per feedback, coverage was extended into
com.jme3.scenewith behavior-oriented tests:SceneGraphIteratorTest— validates depth-first iteration order, depth tracking, subtree skipping viaignoreChildren(),current()semantics, and leaf-spatial iteration behavior.NodeHierarchyBehaviorTest— validates automatic reparenting, hierarchy world-transform propagation (translation + rotation + scale),localToWorld/worldToLocalround-trip invariants, detach behavior preserving local transforms, andswapChildren()effects on traversal order.All tests follow the existing JUnit 4 conventions and exercise complex behavior/invariants, including mutating (
*Local) and non-mutating variants where applicable.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.