Skip to content

Commit f1cf12a

Browse files
committed
New file converted
1 parent 7b5d640 commit f1cf12a

3 files changed

Lines changed: 85 additions & 43 deletions

File tree

spml/src/main/resources/131-java-unit-testing.xml

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -762,30 +762,83 @@ class MyProcessorTest {
762762
<rule-subtitle>Use RIGHT-BICEP to guide comprehensive test creation</rule-subtitle>
763763
</rule-header>
764764
<rule-description>
765-
If the code ran correctly, how would I know? How am I going to test this? What else can go wrong? Could this same kind of problem happen anywhere else? What to Test: Use Your RIGHT-BICEP - Are the results **R**ight? Are all the **B**oundary conditions CORRECT? Can you check **I**nverse relationships? Can you **C**ross-check results using other means? Can you force **E**rror conditions to happen? Are **P**erformance characteristics within bounds?
765+
Key Questions to Guide Test Creation
766766
</rule-description>
767+
<rule-notes>
768+
<notes-title>Description:</notes-title>
769+
<note-item>
770+
<note-term>If the code ran correctly, how would I know?</note-term>
771+
<note-description></note-description>
772+
</note-item>
773+
<note-item>
774+
<note-term>How am I going to test this?</note-term>
775+
<note-description></note-description>
776+
</note-item>
777+
<note-item>
778+
<note-term>What else can go wrong?</note-term>
779+
<note-description></note-description>
780+
</note-item>
781+
<note-item>
782+
<note-term>Could this same kind of problem happen anywhere else?</note-term>
783+
<note-description></note-description>
784+
</note-item>
785+
<note-item>
786+
<note-term>What to Test: Use Your RIGHT-BICEP</note-term>
787+
<note-description></note-description>
788+
</note-item>
789+
<note-item>
790+
<note-term>Are the results **R**ight?</note-term>
791+
<note-description></note-description>
792+
</note-item>
793+
<note-item>
794+
<note-term>Are all the **B**oundary conditions CORRECT?</note-term>
795+
<note-description></note-description>
796+
</note-item>
797+
<note-item>
798+
<note-term>Can you check **I**nverse relationships?</note-term>
799+
<note-description></note-description>
800+
</note-item>
801+
<note-item>
802+
<note-term>Can you **C**ross-check results using other means?</note-term>
803+
<note-description></note-description>
804+
</note-item>
805+
<note-item>
806+
<note-term>Can you force **E**rror conditions to happen?</note-term>
807+
<note-description></note-description>
808+
</note-item>
809+
<note-item>
810+
<note-term>Are **P**erformance characteristics within bounds?</note-term>
811+
<note-description></note-description>
812+
</note-item>
813+
</rule-notes>
767814
<code-examples>
768815
<good-example>
769-
<code-block language="java"><![CDATA[// Example: Testing a Calculator's add method using RIGHT-BICEP
816+
<code-block language="java"><![CDATA[// Testing a calculator's add method, considering RIGHT-BICEP
817+
public class Calculator {
818+
public int add(int a, int b) {
819+
if ((long)a + b > Integer.MAX_VALUE || (long)a + b < Integer.MIN_VALUE) {
820+
throw new ArithmeticException("Integer overflow");
821+
}
822+
return a + b;
823+
}
824+
}
825+
826+
// Test class
770827
import org.junit.jupiter.api.Test;
771828
import static org.assertj.core.api.Assertions.assertThat;
772829
import static org.assertj.core.api.Assertions.assertThatThrownBy;
773830
774831
public class CalculatorTest {
832+
775833
private final Calculator calculator = new Calculator();
776834
777-
// R - Right results (typical cases)
835+
// R - Right results
778836
@Test
779-
void add_twoPositiveNumbers_returnsCorrectSum() {
837+
void add_simplePositiveNumbers_returnsCorrectSum() {
780838
assertThat(calculator.add(2, 3)).isEqualTo(5);
781839
}
782840
783-
// B - Boundary conditions (edge cases: zero, max values)
784-
@Test
785-
void add_zeroAndNumber_returnsNumber() {
786-
assertThat(calculator.add(0, 5)).isEqualTo(5);
787-
}
788-
841+
// B - Boundary conditions (e.g., with zero, negative numbers, max/min values)
789842
@Test
790843
void add_numberAndZero_returnsNumber() {
791844
assertThat(calculator.add(5, 0)).isEqualTo(5);

spml/src/test/java/info/jab/xml/CursorRuleGeneratorTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ void should_generateExactContentMatchingOriginalExpected_when_transformingJavaLo
294294
}
295295

296296
@Test
297-
@Disabled("Content generation mismatch - needs investigation")
298297
@DisplayName("Should generate exact content matching original expected Java Unit Testing document using unified XSLT")
299298
void should_generateExactContentMatchingOriginalExpected_when_transformingJavaUnitTestingWithUnifiedXslt() throws IOException {
300299
// Given

spml/src/test/resources/131-java-unit-testing.mdc

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -702,19 +702,23 @@ class MyProcessorTest {
702702

703703
## Rule 16: Key Questions to Guide Test Creation (RIGHT-BICEP)
704704

705-
Title: Key Questions to Guide Test Creation
706-
Description:
707-
- If the code ran correctly, how would I know?
708-
- How am I going to test this?
709-
- What else can go wrong?
710-
- Could this same kind of problem happen anywhere else?
711-
- What to Test: Use Your RIGHT-BICEP
712-
- Are the results **R**ight?
713-
- Are all the **B**oundary conditions CORRECT?
714-
- Can you check **I**nverse relationships?
715-
- Can you **C**ross-check results using other means?
716-
- Can you force **E**rror conditions to happen?
717-
- Are **P**erformance characteristics within bounds?
705+
Title: Use RIGHT-BICEP to guide comprehensive test creation
706+
Description: Key Questions to Guide Test Creation
707+
708+
**Description:**
709+
710+
* **If the code ran correctly, how would I know?**:
711+
* **How am I going to test this?**:
712+
* **What else can go wrong?**:
713+
* **Could this same kind of problem happen anywhere else?**:
714+
* **What to Test: Use Your RIGHT-BICEP**:
715+
* **Are the results **R**ight?**:
716+
* **Are all the **B**oundary conditions CORRECT?**:
717+
* **Can you check **I**nverse relationships?**:
718+
* **Can you **C**ross-check results using other means?**:
719+
* **Can you force **E**rror conditions to happen?**:
720+
* **Are **P**erformance characteristics within bounds?**:
721+
718722

719723
**Good example:**
720724

@@ -812,14 +816,8 @@ public class CalculatorTestPoor {
812816

813817
## Rule 17: Characteristics of Good Tests (A-TRIP)
814818

815-
Title: Characteristics of Good Tests (A-TRIP)
816-
Description:
817-
Good tests are A-TRIP:
818-
- **A**utomatic: Tests should run without human intervention.
819-
- **T**horough: Test everything that could break; cover edge cases.
820-
- **R**epeatable: Tests should produce the same results every time, in any environment.
821-
- **I**ndependent: Tests should not rely on each other or on the order of execution.
822-
- **P**rofessional: Test code is real code; keep it clean, maintainable, and well-documented.
819+
Title: Good tests are A-TRIP
820+
Description: Good tests are A-TRIP: - **A**utomatic: Tests should run without human intervention. - **T**horough: Test everything that could break; cover edge cases. - **R**epeatable: Tests should produce the same results every time, in any environment. - **I**ndependent: Tests should not rely on each other or on the order of execution. - **P**rofessional: Test code is real code; keep it clean, maintainable, and well-documented.
823821

824822
**Good example:**
825823

@@ -940,16 +938,8 @@ public class BadOrderProcessorTest {
940938

941939
## Rule 18: Verifying CORRECT Boundary Conditions
942940

943-
Title: Verifying CORRECT Boundary Conditions
944-
Description:
945-
Ensure your tests check the following boundary conditions (CORRECT):
946-
- **C**onformance: Does the value conform to an expected format? (e.g., email format, date format)
947-
- **O**rdering: Is the set of values ordered or unordered as appropriate? (e.g., sorted list, items in a queue)
948-
- **R**ange: Is the value within reasonable minimum and maximum values? (e.g., age > 0, percentage 0-100)
949-
- **R**eference: Does the code reference anything external that isn't under direct control of the code itself? (e.g., file existence, network connection - often for integration tests, but can apply to unit tests with mocks)
950-
- **E**xistence: Does the value exist? (e.g., is non-null, non-zero, present in a set)
951-
- **C**ardinality: Are there exactly enough values? (e.g., expecting 1 result, 0 results, N results)
952-
- **T**ime (absolute and relative): Is everything happening in order? At the right time? In time? (e.g., timeouts, sequence of events)
941+
Title: Ensure your tests check CORRECT boundary conditions
942+
Description: Ensure your tests check the following boundary conditions (CORRECT): - **C**onformance: Does the value conform to an expected format? (e.g., email format, date format) - **O**rdering: Is the set of values ordered or unordered as appropriate? (e.g., sorted list, items in a queue) - **R**ange: Is the value within reasonable minimum and maximum values? (e.g., age > 0, percentage 0-100) - **R**eference: Does the code reference anything external that isn't under direct control of the code itself? (e.g., file existence, network connection - often for integration tests, but can apply to unit tests with mocks) - **E**xistence: Does the value exist? (e.g., is non-null, non-zero, present in a set) - **C**ardinality: Are there exactly enough values? (e.g., expecting 1 result, 0 results, N results) - **T**ime (absolute and relative): Is everything happening in order? At the right time? In time? (e.g., timeouts, sequence of events)
953943

954944
**Good example:**
955945

@@ -1079,4 +1069,4 @@ public class UserValidationPoorTest {
10791069
assertThat(validator.isValidEmailFormat("test@example.com")).isTrue(); // No invalid formats, no nulls.
10801070
}
10811071
}
1082-
```
1072+
```

0 commit comments

Comments
 (0)