Migrating from SUnit to Phexample

I tried Pharo Phexample and I like it, but it seems awkward to have half of my unit tests in SUnit and the other half in Fxample. Does Phexample have an import function for my existing tests?

+5
source share
1 answer

Regarding the mathematics of expectations, there are a series of rewrite rules on the part of the class PhexMatcher. This screencast explains how to use the RB: Code Critics rewrite mechanism in OB (Screencast 3 OB) .

Use these rules first

RBParseTreeRewriter new
    replace: 'self assert: [ `@expression ]' with: 'self assert: `@expression';
    replace: 'self deny: `@expression' with: 'self assert: `@expression not';
    yourself.

Then use these rules

RBParseTreeRewriter new
    replace: 'self assert: `@value = `@expected' with: '`@value should = `@expected';
    replace: 'self assert: `@value ~= `@expected' with: '`@value should not = `@expected';
    replace: 'self assert: `@value > `@expected' with: '`@value should > `@expected';
    replace: 'self assert: `@value < `@expected' with: '`@value should < `@expected';
    replace: 'self assert: `@value >= `@expected' with: '`@value should >= `@expected';
    replace: 'self assert: `@value <= `@expected' with: '`@value should <= `@expected';
    replace: 'self assert: (`@value isKindOf: `@type)' with: '`@value should beKindOf: `@type';
    replace: 'self assert: `@expression isNil' with: '`@expression should be isNil';
    replace: 'self assert: `@expression notNil' with: '`@expression should be notNil';
    replace: 'self assert: `@expression `test not' with: '`@expression should not be `test'
        when: [:node | node arguments first receiver selector matchesRegex: '(is|has|not).+|atEnd' ];
    replace: 'self assert: `@expression `test' with: '`@expression should be `test'
        when: [:node | node arguments first selector matchesRegex: '(is|has|not).+|atEnd' ];
    replace: 'self assert: (`@collection includes: `@element) not' with: '`@collection should not be includes: `@element';
    replace: 'self assert: (`@collection includes: `@element)' with: '`@collection should be includes: `@element';
    yourself.

, . JExample JUnit2JExample, , , Smalltalk ().


PS: Pharo, OB OB-Refactory, .

SystemBrowser default: OBSystemBrowserAdaptor.
Gofer new
    wiresong: 'ob';
    addPackage: 'OB-Refactory';
    revert
+5

All Articles