Skip to content

Instantly share code, notes, and snippets.

@boukeversteegh
Created August 11, 2023 13:39
Show Gist options
  • Save boukeversteegh/291c372ab0121166132a5fac657600f3 to your computer and use it in GitHub Desktop.
Save boukeversteegh/291c372ab0121166132a5fac657600f3 to your computer and use it in GitHub Desktop.
Rethinking Boundaries: Merging End-to-End Testing and Implementation with Macro Abstractions

Rethinking Boundaries: Merging End-to-End Testing and Implementation with Macro Abstractions

In traditional software development, there's a clear boundary separating end-to-end testing and implementation. This conventional mindset, however, faces a challenge with the introduction of a unique software development paradigm proposing the unification of these two aspects.

Underpinning this concept, a Domain-Specific Language (DSL) is used. This language serves to sketch out a detailed sequence of actions and responses - acting as test specifications. Interestingly, at the same time, these sequences also provide a functional model of the system's behavior and thus can serve as an efficient implementation.

Let's dive deeper with an example. Consider you are crafting multiple test cases for a basic addition operation in a calculator application. After designing a few tests, you spot a consistent pattern of steps - you enter two numbers, add them together, and finally, you expect a result.

Here is how it would look:

REGISTER ACTION "Start_Calculator"
ACTION "Enter_Input" PARAMS "7"
ACTION "Press_Button" PARAMS "add"
ACTION "Enter_Input" PARAMS "8"
ACTION "Press_Button" PARAMS "equals"
EXPECTED "15"
REGISTER END "End_Calculator"

REGISTER ACTION "Start_Calculator"
ACTION "Enter_Input" PARAMS "10"
ACTION "Press_Button" PARAMS "add"
ACTION "Enter_Input" PARAMS "20"
ACTION "Press_Button" PARAMS "equals"
EXPECTED "30"
REGISTER END "End_Calculator"

The repeated sequences in these test cases hint toward the potential for abstraction. One can introduce a macro, say ADD_AND_VERIFY, to encapsulate the actions and the expected operation in one place:

DEFINE MACRO ADD_AND_VERIFY (Number1, Number2) -> ExpectedResult {
    ACTION "Enter_Input" PARAMS "Number1"
    ACTION "Press_Button" PARAMS "add"
    ACTION "Enter_Input" PARAMS "Number2"
    ACTION "Press_Button" PARAMS "equals"
    EXPECTED
      MATCH (Number1, Number2)
           7, 8 -> 15
           10, 20 -> 30
}

And now, the test cases can be written more succinctly:

ADD_AND_VERIFY (7, 8) -> 15
ADD_AND_VERIFY (10, 20) -> 30

An impressive aspect of this method is the introduction of automated abstraction discovery, facilitated by an AI system. The AI system analyzes these sequences and learns to propose a more generalized implementation dynamically.

This is how the ADD_AND_VERIFY macro could evolve into a broader function:

DEFINE MACRO ADD_AND_VERIFY (Number1, Number2) -> ExpectedResult {
    ACTION "Enter_Input" PARAMS "Number1"
    ACTION "Press_Button" PARAMS "add"
    ACTION "Enter_Input" PARAMS "Number2"
    ACTION "Press_Button" PARAMS "equals"
    EXPECTED Number1 + Number2
}

Significantly, this abstraction process is reversible. Existing macros can readily be replaced with their original content, meaning that as new scenarios are defined, new and improved abstractions can be discovered, and refactoring can become entirely automated.

To sum up, this paradigm fosters a continuous cycle of scenerio description, abstraction, parametrization, and generalization. It drafts an innovative layout where end-to-end testing and program implementation coexist and interchange freely.

Limitations and Challenges: Looking Forward

While the promising concept of converging end-to-end testing with implementation through automated abstractions forms an exciting shift in software development paradigms, it's also important to highlight the potential challenges and limitations this approach may face.

One crucial aspect is the need for every action statement to be defined in two dimensions - its implementation and its means of verification. For simple tasks such as entering a character, the duality is straightforward to manage. However, for more complex actions like pressing a button, a myriad of details associated with UI configuration and behavior would need to be taken into account.

Consider a test sequence involving a button click. Not only does the language need to describe the action of pressing the button but also how the user interface should look like at the time of the button press and how the UI changes in response to the action. This would possibly involve rendering controls and verifying their state during the test sequence.

A potential way around this is to include expected UI state, such as HTML layout, as an output of prior steps. Yet, how an AI model could automatically extract this data from test sequences and translate it into correct implementation and event binding is an uncharted area. Understanding and modeling UI interactions in a verifiable, repeatable manner represent significant challenges in automating this abstraction process.

Additionally, system state changes and workflows that include server responses or operation of multiple software components simultaneously are complex to capture within a DSL and to abstract using automated procedures.

As we step into this new paradigm, these challenges open up areas of study and focus. The journey to knitting end-to-end testing tightly with implementation is abound with fascinating challenges and unending opportunities for innovation. The journey, however, is just beginning, and it's a road that's bound to redefine the horizons of software development.


TLDR

  • A proposed paradigm merges end-to-end testing and software implementation.
  • Reusable macros abstract repetitive sequences in test cases, and form the actual implementation
  • Macro "de-abstracting" enables flexibility for test and implementation adjustments.
  • AI identifies patterns within sequences to suggest generalized implementations.
  • Challenges lie in defining complex tasks that involve UI changes and event binding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment