### Build and Package Extension Source: https://github.com/adamwong246/testeranto/blob/master/README-VSCODE.md Commands to build and package the extension for local installation. ```bash npm run bundle ``` ```bash npm run package ``` -------------------------------- ### Docker Configuration for Rubeno Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/rubeno/README.md Example Dockerfile setup for running Rubeno tests within a Ruby 3.2 Alpine container. ```dockerfile FROM ruby:3.2-alpine WORKDIR /workspace # ... (see testeranto/runtimes/ruby/ruby.Dockerfile) ``` -------------------------------- ### Install package in development mode Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/pitono/README.md Installs the package in editable mode to allow for local development changes. ```bash pip install -e . ``` -------------------------------- ### Metafile JSON Structure Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/golingvu/README.md Example of the metafile schema used to track inputs, outputs, and signatures. ```json { "errors": [], "warnings": [], "metafile": { "inputs": { "path/to/file.ext": { "bytes": 1024, "imports": ["dependency1", "dependency2"] } }, "outputs": { "output/path/file.ext": { "imports": [], "exports": [], "entryPoint": "original/file.ext", "inputs": { "original/file.ext": { "bytesInOutput": 1024 } }, "bytes": 1024, "signature": "unique_id" } } } } ``` -------------------------------- ### Create a virtual environment Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/pitono/README.md Initializes a new Python virtual environment in the current directory. ```bash python3 -m venv venv ``` -------------------------------- ### Define and run a basic test in Java Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/kafe/README.md Initializes a test implementation and specification, then executes the test using the Kafe orchestrator. ```java import kafe.*; import java.util.*; public class CalculatorTest { public static void main(String[] args) { // Define test implementation Map suites = new HashMap<>(); Map> givens = new HashMap<>(); Map>> whens = new HashMap<>(); Map>> thens = new HashMap<>(); // Add your test definitions here... ITestImplementation implementation = new ITestImplementation( suites, givens, whens, thens ); // Create test specification ITestSpecification specification = (suitesObj, givensObj, whensObj, thensObj) -> { // Build test specs return new ArrayList<>(); }; // Create Kafe instance Kafe kafe = new Kafe( null, specification, implementation, new ITestResourceRequest(1), new SimpleTestAdapter(), (runnable) -> { runnable.run(); return null; } ); // Run tests IFinalResults results = kafe.receiveTestResourceConfig( "{\"name\":\"test\",\"fs\":\".\",\"ports\":[]}", "ipcfile" ); System.exit(results.fails); } } ``` -------------------------------- ### Initialize and run a Rusto test Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/rusto/README.md Define the test implementation and execute tests using the Rusto instance and a test adapter. ```rust use rusto::{Rusto, SimpleTestAdapter, ITestImplementation, ITestSpecification}; use async_trait::async_trait; // Define your test implementation let implementation = ITestImplementation { suites: /* ... */, givens: /* ... */, whens: /* ... */, thens: /* ... */, }; // Create Rusto instance let rusto = Rusto::new( input, test_specification, implementation, test_resource_requirement, Box::new(SimpleTestAdapter::new()), ); // Run tests let results = rusto.receive_test_resource_config(partial_test_resource).await; ``` -------------------------------- ### Implement a Custom Adapter Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/rubeno/README.md Creates a custom test adapter by including the Rubeno::ITestAdapter module and implementing required methods. ```ruby class CustomAdapter include Rubeno::ITestAdapter def before_all(input_val, tr, pm) # Custom setup input_val end # ... implement other methods end ``` -------------------------------- ### Execute tests via command line Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/kafe/README.md Runs the Kafe test suite using the Java classpath. ```bash java -cp ".:kafe/*" kafe.Kafe '{"name":"test","fs":".","ports":[]}' ``` -------------------------------- ### Execute tests via CLI Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/rusto/README.md Run the project's test suite using the standard cargo command. ```bash cargo test ``` -------------------------------- ### Define and Run a Rubeno Test Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/rubeno/README.md Configures a test implementation and specification, then initializes and executes the Rubeno test instance. ```ruby require 'rubeno' # Define test implementation test_implementation = Rubeno::ITestImplementation.new( suites: { 'Default' => ->(name, givens) { ... } }, givens: { 'basic' => ->(initial_values) { ... } }, whens: { 'press' => ->(button) { ->(store) { ... } } }, thens: { 'displayIs' => ->(expected) { ->(store) { ... } } } ) # Define test specification test_specification = ->(suites, givens, whens, thens) do [ suites.Default('Test Suite', { 'test1' => givens.basic([], [whens.press('1')], [thens.displayIs('1')], nil) }) ] end # Create test instance test_instance = Rubeno.Rubeno( nil, test_specification, test_implementation, Rubeno::SimpleTestAdapter.new, Rubeno::ITTestResourceRequest.new(ports: 1) ) # Set as default and run Rubeno.set_default_instance(test_instance) Rubeno.main ``` -------------------------------- ### Initialize Testeranto Runtimes Source: https://github.com/adamwong246/testeranto/blob/master/docs/index.md The entry point for configuring and running tests across Node, Web, or Pure environments using the same structural pattern. ```typescript import Testeranto from "testeranto/src/Node"; // <- import the Node main function // below this point, all runtimes are identical! import { implementation } from "./Rectangle.test.implementation"; import { specification } from "./Rectangle.test.specification"; import { adapter } from "./Rectangle.test.adapter"; // Note the type parameters I, O, and M: these will be important later export default Testeranto< I extends Ibdd_in, O extends Ibdd_out, M >( Rectangle.prototype, // <- the subject of the test. specification, implementation, adapter ); ``` ```typescript import Testeranto from "testeranto/src/Web"; // <- import the Web main function // below this point, all runtimes are identical! import { implementation } from "./Rectangle.test.implementation"; import { specification } from "./Rectangle.test.specification"; import { adapter } from "./Rectangle.test.adapter"; // Note the type parameters I, O, and M: these will be important later export default Testeranto< I extends Ibdd_in, O extends Ibdd_out, M >( Rectangle.prototype, // <- the subject of the test. specification, implementation, adapter ); ``` ```typescript import Testeranto from "testeranto/src/Pure"; // <- import the Pure main function // below this point, all runtimes are identical! import { implementation } from "./Rectangle.test.implementation"; import { specification } from "./Rectangle.test.specification"; import { adapter } from "./Rectangle.test.adapter"; // Note the type parameters I, O, and M: these will be important later export default Testeranto< I extends Ibdd_in, O extends Ibdd_out, M >( Rectangle.prototype, // <- the subject of the test. specification, implementation, adapter ); ``` -------------------------------- ### Activate the virtual environment Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/pitono/README.md Activates the previously created virtual environment for the current shell session. ```bash source venv/bin/activate ``` -------------------------------- ### Implement Language Watcher Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/golingvu/README.md Template for setting up source and bundle file watchers for new language support. ```typescript export class [Language]Watcher { async start() { // Set up source file watcher // Set up bundle file watcher // Handle file change events } private async regenerateMetafile() { // Regenerate metafile and output files } } ``` -------------------------------- ### Compile Extension Source: https://github.com/adamwong246/testeranto/blob/master/README-VSCODE.md Command to compile TypeScript files and bundle the extension for development. ```bash npm run bundle ``` -------------------------------- ### Execute Rubeno Tests via CLI Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/rubeno/README.md Runs a Ruby test file by passing a JSON configuration string as an argument. ```bash ruby example/Calculator-test.rb '{"name":"test","fs":".","ports":[]}' ``` -------------------------------- ### Compile Java source files Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/kafe/README.md Compiles all Java files within the kafe library directory. ```bash cd src/lib/kafe javac -d . *.java ``` -------------------------------- ### Define Test Implementation Source: https://github.com/adamwong246/testeranto/blob/master/docs/index.md Use ITestImplementation to define suites, givens, whens, and thens for your test logic. ```typescript import { Ibdd_in, Ibdd_out, ITestImplementation, } from "testeranto/src/CoreTypes"; // Note the type parameters I and O. These are important! export const implementation: ITestImplementation< I extends Ibdd_in, O extends Ibdd_out, M > = { suites: { Default: "a default suite", }, givens: { Default: () => new Rectangle(2, 2), WidthAndHeightOf: (width, height) => new Rectangle(width, height), }, whens: { setWidth: (width: number) => (rectangle) => { rectangle.setWidth(width); return rectangle; }, setHeight: (height: number) => (rectangle) => { rectangle.setHeight(height); return rectangle; }, }, thens: { getWidth: (expectedWidth) => (rectangle) => { assert.equal(rectangle.getWidth(), expectedWidth); return rectangle; }, getHeight: (expectedHeight) => (rectangle) => { assert.equal(rectangle.getHeight(), expectedHeight); return rectangle; }, area: (area) => (rectangle) => { assert.equal(rectangle.area(), area); return rectangle; }, circumference: (circumference: number) => (rectangle: Rectangle) => { assert.equal(rectangle.circumference(), circumference); return rectangle; }, } }; ``` -------------------------------- ### Apply Color Sampler Styles Source: https://github.com/adamwong246/testeranto/blob/master/docs/style.md CSS styles for rendering the color swatches and layout of the color sampler component. ```css .color-sampler { margin: 2rem 0; max-width: 800px; } .color-group { margin-bottom: 2rem; } .color-row { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; } .color-swatch { flex: 1; min-width: 150px; padding: 1rem; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100px; transition: transform 0.2s ease; } .color-swatch:hover { transform: translateY(-5px); } .hex { font-family: monospace; font-weight: bold; font-size: 1.1rem; } .name { font-style: italic; margin-top: 0.5rem; } ``` -------------------------------- ### Calculator Implementation Source: https://github.com/adamwong246/testeranto/blob/master/testeranto/bundles/allTests/python/Calculator.pitono.test.txt Provides the basic arithmetic operations for the Calculator class. ```python class Calculator: def add(self, a, b): return a + b ``` -------------------------------- ### Add Rusto dependency to Cargo.toml Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/rusto/README.md Include the local path to the rusto crate in your project's dependency configuration. ```toml [dependencies] rusto = { path = "./src/lib/rusto" } ``` -------------------------------- ### Define Metafile Generator Interface Source: https://github.com/adamwong246/testeranto/blob/master/src/lib/golingvu/README.md Template for implementing metafile generation logic for new languages. ```typescript export async function generate[Language]Metafile( testName: string, entryPoints: string[] ): Promise<[Language]Metafile> { // Parse entry point files to find imports/dependencies // Generate unique signature // Return metafile structure with inputs and outputs } export function write[Language]Metafile( testName: string, metafile: [Language]Metafile ): void { // Write metafile to disk // Generate output wrapper files with signatures } ``` -------------------------------- ### Define Test Adapter Source: https://github.com/adamwong246/testeranto/blob/master/docs/index.md Implement ITestAdapter to handle BDD lifecycle hooks like before/after each test. ```typescript import { Ibdd_in, ITestAdapter, } from "testeranto/src/CoreTypes"; // Note the type parameter. This is important! export const testAdapter: ITestAdapter< I extends Ibdd_in, > = { beforeEach: async (subject, i) => { return i(); }, andWhen: async function (s, whenCB, tr, utils) { return whenCB(s, utils); }, butThen: async (s, t, tr, pm) => { return t(s, pm); }, afterEach: (z) => { return z; }, afterAll: () => {}, assertThis: (x: any, y) => {}, }; ``` -------------------------------- ### Define and Execute Testeranto Tests Source: https://github.com/adamwong246/testeranto/blob/master/docs/index.md Configures a test subject, defines BDD types for givens/whens/thens, and provides the implementation and specification for test execution. ```typescript // Make sure you import the right runtime import Testeranto from "testeranto/src/Pure"; import { Ibdd_in, Ibdd_out, ITestImplementation, ITestSpecification, ITestAdapter, } from "testeranto/src/CoreTypes"; // The test subject class Rectangle { constructor(public width: number, public height: number) {} setWidth(w: number) { this.width = w; } setHeight(h: number) { this.height = h; } getArea() { return this.width * this.height; } } //////////////////////////////////////////////////////// // TODO this is inaccurate type I = Ibdd_in< null, null, Rectangle, Rectangle, Rectangle, (...x) => (rectangle: Rectangle, utils: IPM) => Rectangle, (rectangle: Rectangle, utils: IPM) => Rectangle >; type O = Ibdd_out< // Suites { Default: [string]; }, // Givens { Default; WidthOfOneAndHeightOfOne; WidthAndHeightOf: [number, number]; }, // Whens { HeightIsPubliclySetTo: [number]; WidthIsPubliclySetTo: [number]; setWidth: [number]; setHeight: [number]; }, // Thens { AreaPlusCircumference: [number]; circumference: [number]; getWidth: [number]; getHeight: [number]; area: [number]; prototype: []; }, // Checks are broken right now, ignore them { Default; WidthOfOneAndHeightOfOne; WidthAndHeightOf: [number, number]; } >; type M = { givens: { [K in keyof O["givens"]]: (...Iw: O["givens"][K]) => Rectangle; }; whens: { [K in keyof O["whens"]]: ( ...Iw: O["whens"][K] ) => (rectangle: Rectangle, utils: PM) => Rectangle; }; thens: { [K in keyof O["thens"]]: ( ...Iw: O["thens"][K] ) => (rectangle: Rectangle, utils: PM) => Rectangle; }; }; const testAdapter: ITestAdapter< I extends Ibdd_in, > = { beforeEach: async (subject, i) => { return i(); }, andWhen: async function (s, whenCB, tr, utils) { return whenCB(s, utils); }, butThen: async (s, t, tr, pm) => { return t(s, pm); }, afterEach: (z) => { return z; }, afterAll: () => {}, assertThis: (x: any, y) => {}, }; const testImplementation: ITestImplementation< I extends Ibdd_in, O extends Ibdd_out, M > = { suites: { Default: "a default suite", }, givens: { Default: () => new Rectangle(2, 2), WidthAndHeightOf: (width, height) => new Rectangle(width, height), }, whens: { setWidth: (width: number) => (rectangle) => { rectangle.setWidth(width); return rectangle; }, setHeight: (height: number) => (rectangle) => { rectangle.setHeight(height); return rectangle; }, }, thens: { getWidth: (expectedWidth) => (rectangle) => { assert.equal(rectangle.getWidth(), expectedWidth); return rectangle; }, getHeight: (expectedHeight) => (rectangle) => { assert.equal(rectangle.getHeight(), expectedHeight); return rectangle; }, area: (area) => (rectangle) => { assert.equal(rectangle.area(), area); return rectangle; }, circumference: (circumference: number) => (rectangle: Rectangle) => { assert.equal(rectangle.circumference(), circumference); return rectangle; }, } }; const testSpecification: ITestSpecification< I extends Ibdd_in, O extends Ibdd_out, > = ( Suite, Given, When, Then, Check ) => { return [ Suite.Default( "Testing the Rectangle class", { test0: Given.Default( ["https://api.github.com/repos/adamwong246/testeranto/issues/8"], [], [Then.getWidth(2)] ), test1: Given.Default( [`Rectangles have width and height.`], [When.setWidth(4), When.setHeight(5)], [Then.getWidth(4), Then.getHeight(5), Then.area(20)] ), }, // Ignore this for now [] ), ]; }; // 1 function will launch the test export default Testeranto< I extends Ibdd_in, O extends Ibdd_out, M >( Rectangle.prototype, testSpecification, testSmplementation, testSnterface ); ``` -------------------------------- ### Testeranto Main Function Signature Source: https://github.com/adamwong246/testeranto/blob/master/docs/index.md The primary function used to launch and execute tests, requiring specific input, specification, implementation, and adapter types. ```typescript async ( input: I["iinput"], testSpecification: ITestSpecification, testImplementation: ITestImplementation, testAdapter: Partial>, testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement ): Promise> ``` -------------------------------- ### Integrate consoleDetectorPlugin into esbuild Source: https://github.com/adamwong246/testeranto/blob/master/src/esbuildConfigs/README.md Add the plugin to the plugins array within your esbuild configuration object. ```javascript import { consoleDetectorPlugin } from "./consoleDetectorPlugin"; // Add to your esbuild config esbuild.build({ plugins: [consoleDetectorPlugin], // ... other config }); ``` -------------------------------- ### Calculator Test Definition Source: https://github.com/adamwong246/testeranto/blob/master/testeranto/bundles/allTests/python/Calculator.pitono.test.txt Defines the test cases for the Calculator component using the Testeranto framework. ```python import unittest from Calculator import Calculator class TestCalculator(unittest.TestCase): def test_add(self): calc = Calculator() self.assertEqual(calc.add(1, 2), 3) if __name__ == '__main__': unittest.main() ``` -------------------------------- ### Define TestPageViewProps interface Source: https://github.com/adamwong246/testeranto/blob/master/docs/test-page-components.md Interface defining the required properties for the TestPageView presentational component. ```typescript interface TestPageViewProps { projectName: string; testName: string; decodedTestPath: string; runtime: string; logs: Record; testsExist: boolean; errorCounts: { runTimeErrors: number; typeErrors: number; staticErrors: number; }; } ``` -------------------------------- ### Define Test Specification Source: https://github.com/adamwong246/testeranto/blob/master/docs/index.md The ITestSpecification defines business requirements using Given/When/Then patterns, decoupled from implementation details. ```typescript import { Ibdd_in, Ibdd_out, ITestSpecification, } from "testeranto/src/CoreTypes"; // Note the type parameters I and O. These are important! export const specification: ITestSpecification< I extends Ibdd_in, O extends Ibdd_out, > = ( Suite, Given, When, Then, Check ) => { return [ Suite.Default( "Testing the Rectangle class", { test0: Given.Default( ["https://api.github.com/repos/adamwong246/testeranto/issues/8"], [], [Then.getWidth(2)] ), test1: Given.Default( [`Rectangles have width and height.`], [When.setWidth(4), When.setHeight(5)], [Then.getWidth(4), Then.getHeight(5), Then.area(20)] ), }, // Ignore this for now [] ), ]; }; ``` -------------------------------- ### Define the Test Subject Source: https://github.com/adamwong246/testeranto/blob/master/docs/index.md A simple class implementation to be used as the subject of testing. ```typescript class Rectangle { constructor(public width: number, public height: number) {} setWidth(w: number) { this.width = w; } setHeight(h: number) { this.height = h; } getArea() { return this.width * this.height; } } ``` -------------------------------- ### Define Inner BDD Type (Ibdd_in) Source: https://github.com/adamwong246/testeranto/blob/master/docs/index.md Use Ibdd_in to describe the inner shape and state transitions of the test subject. ```typescript import { Ibdd_in } from "testeranto/src/CoreTypes"; // TODO this is inaccurate export type I = Ibdd_in< null, null, Rectangle, Rectangle, Rectangle, (...x) => (rectangle: Rectangle, utils: IPM) => Rectangle, (rectangle: Rectangle, utils: IPM) => Rectangle >; ``` -------------------------------- ### Define Outer BDD Type (Ibdd_out) Source: https://github.com/adamwong246/testeranto/blob/master/docs/index.md Use Ibdd_out to define the set of legal BDD clauses for your specification. ```typescript import { Ibdd_out } from "testeranto/src/CoreTypes"; export type O = Ibdd_out< // Suite { Default: [string]; }, // "Given" are initial states { Default; WidthOfOneAndHeightOfOne; WidthAndHeightOf: [number, number]; }, // "Whens" are steps which change the state of the test subject { HeightIsPubliclySetTo: [number]; WidthIsPubliclySetTo: [number]; setWidth: [number]; setHeight: [number]; }, // "Thens" are steps which make assertions of the test subject { AreaPlusCircumference: [number]; circumference: [number]; getWidth: [number]; getHeight: [number]; area: [number]; prototype: []; }, // "Checks" are similar to "Givens" { Default; WidthOfOneAndHeightOfOne; WidthAndHeightOf: [number, number]; } >; ``` -------------------------------- ### Define Optional Modification Type (M) Source: https://github.com/adamwong246/testeranto/blob/master/docs/index.md Use type M to define modifications to the specification shape for DRYer test definitions. ```typescript export type M = { givens: { [K in keyof O["givens"]]: (...Iw: O["givens"][K]) => Rectangle; }; whens: { [K in keyof O["whens"]]: ( ...Iw: O["whens"][K] ) => (rectangle: Rectangle, utils: PM) => Rectangle; }; thens: { [K in keyof O["thens"]]: ( ...Iw: O["thens"][K] ) => (rectangle: Rectangle, utils: PM) => Rectangle; }; }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.