JUnitTestCaseProxy.st
author Marcel Hlopko <marcel.hlopko@gmail.com>
Sat, 08 Feb 2014 22:13:44 +0100
branchdevelopment
changeset 3011 83579e128194
parent 2982 673487527490
child 3012 8a803c26ea93
permissions -rw-r--r--
teach JUnitTestCaseProxy of expected exceptions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     1
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
     3
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
     4
 New code and modifications done at SWING Research Group [1]:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
     5
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     6
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     7
                            SWING Research Group, Czech Technical University in Prague
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     8
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     9
 This software is furnished under a license and may be used
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    10
 only in accordance with the terms of that license and with the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    12
 be provided or otherwise made available to, or used by, any
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    13
 other person.  No title to or ownership of the software is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    14
 hereby transferred.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    15
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    16
 [1] Code written at SWING Research Group contains a signature
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    17
     of one of the above copright owners. For exact set of such code,
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    18
     see the differences between this version and version stx:libjava
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    19
     as of 1.9.2010
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    20
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    21
"{ Package: 'stx:libjava' }"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    22
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    23
JavaTestCaseProxy subclass:#JUnitTestCaseProxy
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    24
	instanceVariableNames:''
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    25
	classVariableNames:''
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    26
	poolDictionaries:''
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    27
	category:'Languages-Java-Tests-Proxies'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    28
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    29
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    30
!JUnitTestCaseProxy class methodsFor:'documentation'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    31
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    32
copyright
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    33
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    34
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    35
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    36
 New code and modifications done at SWING Research Group [1]:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    37
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    38
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    39
                            SWING Research Group, Czech Technical University in Prague
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    40
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    41
 This software is furnished under a license and may be used
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    42
 only in accordance with the terms of that license and with the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    43
 inclusion of the above copyright notice.   This software may not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    44
 be provided or otherwise made available to, or used by, any
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    45
 other person.  No title to or ownership of the software is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    46
 hereby transferred.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    47
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    48
 [1] Code written at SWING Research Group contains a signature
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    49
     of one of the above copright owners. For exact set of such code,
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    50
     see the differences between this version and version stx:libjava
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    51
     as of 1.9.2010
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    52
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    53
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    54
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    55
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    56
!JUnitTestCaseProxy class methodsFor:'initialization'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    57
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    58
initialize
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    59
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    60
    TestCases := Dictionary new.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    61
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    62
    "Created: / 01-03-2011 / 10:43:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    63
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    64
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    65
!JUnitTestCaseProxy class methodsFor:'accessing'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    66
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    67
lookupHierarchyRoot
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    68
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    69
    ^JUnitTestCaseProxy
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    70
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    71
    "Created: / 01-03-2011 / 11:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    72
    "Modified: / 01-03-2011 / 14:54:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    73
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    74
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    75
!JUnitTestCaseProxy class methodsFor:'private'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    76
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    77
isTestSelector: selector
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    78
    | javaClass |
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    79
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    80
    self == JUnitTestCaseProxy ifTrue:[ ^ #() ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    81
    javaClass := self javaClass.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    82
    (javaClass includesBehavior:(JavaVM classForName:'junit.framework.TestCase')) 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    83
        ifTrue:[ ^ selector startsWith:'test' ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    84
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    85
    self testSelectors includes: selector.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    86
    "
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    87
        (JUnitTestCase for: JAVA::stx::libjava::tests::junit::JUnit3Tests)
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    88
            testSelectors"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    89
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    90
    "Created: / 17-04-2012 / 22:48:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    91
!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
    92
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    93
testSelectors
2919
d4ef0fe45599 Fix in JUnitTestCaseProxy>>#testSelectors.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
    94
    | javaClass testMethods ignoredMethods |
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    95
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    96
    self == JUnitTestCaseProxy ifTrue:[ ^ #() ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    97
    javaClass := self javaClass.
2919
d4ef0fe45599 Fix in JUnitTestCaseProxy>>#testSelectors.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
    98
d4ef0fe45599 Fix in JUnitTestCaseProxy>>#testSelectors.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
    99
    "/ Old JUnit 3.x style...
d4ef0fe45599 Fix in JUnitTestCaseProxy>>#testSelectors.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   100
    (javaClass includesBehavior:(JavaVM classForName:'junit.framework.TestCase')) ifTrue:[ 
d4ef0fe45599 Fix in JUnitTestCaseProxy>>#testSelectors.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   101
        ^ javaClass selectors select:[:sel | sel startsWith:'test' ]. 
d4ef0fe45599 Fix in JUnitTestCaseProxy>>#testSelectors.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   102
    ].
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   103
2919
d4ef0fe45599 Fix in JUnitTestCaseProxy>>#testSelectors.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   104
    "/ New JUnit 4.x style
d4ef0fe45599 Fix in JUnitTestCaseProxy>>#testSelectors.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   105
    testMethods := (javaClass selectMethodsAnnotatedWith: 'Lorg/junit/Test;' "Has to be type name!!!!!!").
d4ef0fe45599 Fix in JUnitTestCaseProxy>>#testSelectors.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   106
    ignoredMethods := (javaClass selectMethodsAnnotatedWith: 'Lorg/junit/Ignore;' "Has to be type name!!!!!!").
d4ef0fe45599 Fix in JUnitTestCaseProxy>>#testSelectors.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   107
d4ef0fe45599 Fix in JUnitTestCaseProxy>>#testSelectors.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   108
    ^ ( testMethods \ ignoredMethods ) collect:[:m | m selector ].
d4ef0fe45599 Fix in JUnitTestCaseProxy>>#testSelectors.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   109
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   110
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   111
    "
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   112
        (JUnitTestCase for: JAVA::stx::libjava::tests::junit::JUnit3Tests)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   113
            testSelectors"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   114
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   115
    "Created: / 01-03-2011 / 10:49:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   116
    "Modified: / 03-03-2011 / 00:34:39 / Marcel Hlopko <hlopik@gmail.com>"
2919
d4ef0fe45599 Fix in JUnitTestCaseProxy>>#testSelectors.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   117
    "Modified: / 14-11-2013 / 11:59:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   118
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   119
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   120
!JUnitTestCaseProxy class methodsFor:'subclass creation'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   121
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   122
for:javaClass 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   123
    "Answers a new (anonymous) testcase proxy for
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   124
     given javaClass"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   125
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   126
    self assert:javaClass isJavaClass description:'Not a java class'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   127
    self assert:javaClass isTestCaseLike
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   128
        description:'Not a testcase-like class'.    
2841
6fa1bcf9c997 JavaClass>>#name vs. #binaryName refactoring
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2731
diff changeset
   129
    ^self forClassNamed: javaClass binaryName
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   130
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   131
    "Created: / 01-03-2011 / 10:30:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   132
    "Modified: / 03-03-2011 / 00:20:49 / Marcel Hlopko <hlopik@gmail.com>"
2841
6fa1bcf9c997 JavaClass>>#name vs. #binaryName refactoring
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2731
diff changeset
   133
    "Modified: / 08-10-2013 / 22:28:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   134
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   135
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   136
!JUnitTestCaseProxy methodsFor:'accessing'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   137
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   138
nameForHDTestReport
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   139
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   140
    ^self class javaClassName copyReplaceAll:$/ with: $.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   141
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   142
    "Created: / 01-04-2011 / 16:10:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   143
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   144
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   145
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   146
selectorForHDTestReport
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   147
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   148
	^testSelector upTo:$(
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   149
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   150
!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   151
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   152
shouldSkip
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   153
    "Returns true, if this testcase should be skipped when a testsuite is run.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   154
     This inly a hint, a test runner is not obliged to respect return value.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   155
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   156
     Currently, the only user is stx/goodies/builder/reports"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   157
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   158
    | method |
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   159
    method := self javaClass lookupMethodFor: testSelector.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   160
    ^method notNil and:[(method annotations runtimeVisible includesKey: 'Lorg/junit/Ignore;')].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   161
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   162
    "Created: / 03-12-2012 / 22:02:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   163
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   164
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   165
!JUnitTestCaseProxy methodsFor:'private'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   166
3011
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   167
handleRaisedException:ex
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   168
   "Some methods are expected to raise an exception, I take care of that. If the exception
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   169
   is not expected, I convert it to something expected by stx tools."    
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   170
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   171
    | method |
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   172
    method := self javaClass lookupMethodFor: testSelector.
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   173
    method notNil ifTrue:[
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   174
        |annotation|
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   175
        annotation := (method annotations runtimeVisible at:'Lorg/junit/Test;').
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   176
        (annotation values includesKey: 'expected') ifTrue: [
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   177
            |classNameIndex className expectedExceptionClass|
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   178
            classNameIndex :=  (annotation values at: 'expected') classIndex.
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   179
            className := (self javaClass constantPool at: classNameIndex).
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   180
            expectedExceptionClass := Java classForName: className.
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   181
            (ex equalsOrIsSubclassOf: expectedExceptionClass) ifTrue: [
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   182
                "this is the expected exception, just continue"
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   183
                ^ self.
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   184
            ].
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   185
        ].
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   186
    ].
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   187
    TestResult failure sunitSignalWith: ex getMessage.
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   188
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   189
    "Created: / 08-02-2014 / 21:31:16 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   190
!
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   191
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   192
performTest
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   193
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   194
    <resource: #skipInDebuggersWalkBack>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   195
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   196
    | assertions |
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   197
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   198
    assertions := SignalSet 
3011
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   199
                    with: (Java classForName:'java.lang.AssertionError')                    
2982
673487527490 Fix in JUnitTestCaseProxy>>performTest.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2919
diff changeset
   200
                    with: (Java classForName:'junit.framework.AssertionFailedError')
3011
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   201
                    with: (Java classForName:'java.lang.RuntimeException')
2982
673487527490 Fix in JUnitTestCaseProxy>>performTest.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2919
diff changeset
   202
                    "/ JavaVM unimplementedNativeMethodSignal is Signal, not exception.
673487527490 Fix in JUnitTestCaseProxy>>performTest.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2919
diff changeset
   203
                    "/ Therefore it MUST be listed here!!!!!!
673487527490 Fix in JUnitTestCaseProxy>>performTest.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2919
diff changeset
   204
                    with: (JavaVM unimplementedNativeMethodSignal).
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   205
    [
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   206
        self javaClass new perform: testSelector sunitAsSymbol
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   207
    ] on: assertions do: [:ex|
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   208
        "This is the tricky part. We have to auto-magically convert
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   209
         jUnit's AssertionFailedError to sUnits TestFailure's"
3011
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   210
        self handleRaisedException: ex.
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   211
    ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   212
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   213
    "Created: / 01-03-2011 / 14:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2982
673487527490 Fix in JUnitTestCaseProxy>>performTest.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2919
diff changeset
   214
    "Modified: / 22-01-2014 / 14:40:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3011
83579e128194 teach JUnitTestCaseProxy of expected exceptions
Marcel Hlopko <marcel.hlopko@gmail.com>
parents: 2982
diff changeset
   215
    "Modified: / 08-02-2014 / 21:31:16 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   216
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   217
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   218
!JUnitTestCaseProxy class methodsFor:'documentation'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   219
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   220
version_CVS
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2396
diff changeset
   221
    ^ '$Header: /cvs/stx/stx/libjava/JUnitTestCaseProxy.st,v 1.4 2013-09-06 00:41:08 vrany Exp $'
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   222
!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   223
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   224
version_HG
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   225
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   226
    ^ '$Changeset: <not expanded> $'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   227
!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   228
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   229
version_SVN
2731
13f5be2bf83b Merged d87e89dd5276 and fe83a843a7bf (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2711 2678
diff changeset
   230
    ^ 'Id'
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   231
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   232
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2152
diff changeset
   233
2152
1cbdfbcc685c Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 749
diff changeset
   234
JUnitTestCaseProxy initialize!