2009-11-20 23 views
5

Sto provando lo Phexample di Pharo e mi piace, ma mi sembra maldestro avere metà dei miei test unitari in SUnit e l'altra metà in Phexample. Phexample ha una funzione di importazione per i miei test esistenti?Migrazione da SUnit a Phexample

risposta

5

Per quanto riguarda gli abbinamenti di attesa, esiste una serie di regole di riscrittura sul lato classe di PhexMatcher. Questo screencast spiega come utilizzare il motore di riscrittura di RB: Code Critics in OB (OB Screencast 3).

prima volta l'uso di queste regole

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

Poi utilizzare queste regole

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. 

Per quanto riguarda l'introduzione delle dipendenze tra i test, è necessario riscrivere i test a mano. Per JExample c'è JUnit2JExample ma purtroppo non c'è ancora una migrazione automatica per Smalltalk (ancora).


PS: se si utilizza l'immagine Pharo ultima è necessario utilizzare l'OB e ripristinare il pacchetto di OB-Refactory per ottenere regole di riscrittura con ambito di lavoro. Basta eseguire

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

Che bello! Vorrei che tutte le librerie fornissero le regole di riscrittura :) –