/
TESTES-UNITARIOS.xml
207 lines (177 loc) · 6.65 KB
/
TESTES-UNITARIOS.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="IRIS" version="26" zv="IRIS for Windows (x86-64) 2021.1 (Build 215.3U)" ts="2022-03-22 07:53:19">
<Class name="Desenvolvimento.Calculadora">
<Super>%RegisteredObject</Super>
<TimeChanged>66124,44349.889318</TimeChanged>
<TimeCreated>66012,72084.691003</TimeCreated>
<Method name="Soma">
<Description>
Recebe dois parametros inteiros, e retorna a soma dos dois valores</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>pValor1:%Integer,pValor2:%Integer</FormalSpec>
<ReturnType>%Integer</ReturnType>
<Implementation><![CDATA[ return pValor1 + pValor2
]]></Implementation>
</Method>
<Method name="Subtrair">
<Description>
Recebe dois parametros inteiros, e retorna a subtracao do primeiro valor pelo segundo.</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>pValor1:%Integer,pValor2:%Integer</FormalSpec>
<ReturnType>%Integer</ReturnType>
<Implementation><![CDATA[ return pValor1 - pValor2
]]></Implementation>
</Method>
<Method name="Divisao">
<Description>
Recebe dois parametros inteiros, e retorna a divisão do primeiro valor pelo segundo.</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>pValor1:%Integer,pValor2:%Integer</FormalSpec>
<ReturnType>%Integer</ReturnType>
<Implementation><![CDATA[ return pValor1 / pValor2
]]></Implementation>
</Method>
</Class>
<Class name="Desenvolvimento.testesUnitarios.CalculadoraTest">
<Super>Desenvolvimento.utils.testesUnitarios</Super>
<TimeChanged>66190,28287.659279</TimeChanged>
<TimeCreated>66005,33526.22863</TimeCreated>
<Parameter name="PACOTECOLECAOTESTES">
<Default>Desenvolvimento.testesUnitarios</Default>
</Parameter>
<Method name="TestSomaDoisNumerosInteiros">
<Implementation><![CDATA[
Set retorno = ##class(Desenvolvimento.Calculadora).Soma(2,2)
Do $$$AssertEquals(retorno,4, "Teste Soma(2,2)=4")
]]></Implementation>
</Method>
<Method name="TestSubtrair">
<Implementation><![CDATA[
Set obj = ##class(Desenvolvimento.Calculadora).%New()
Set retorno = obj.Subtrair(2,1)
Do $$$AssertEquals(retorno,1, "Teste Subtrair(2,1)=1")
]]></Implementation>
</Method>
<Method name="TestDivisao">
<Implementation><![CDATA[
Set obj = ##class(Desenvolvimento.Calculadora).%New()
Set retorno = obj.Divisao(2,1)
Do $$$AssertEquals(retorno,1, "Teste Divisao(2,0)=1")
]]></Implementation>
</Method>
<Method name="ExecutarTestes">
<ClassMethod>1</ClassMethod>
<Implementation><![CDATA[
Set teste = $CLASSMETHOD($THIS,"%New")
Set Status = teste.Executar()
]]></Implementation>
</Method>
</Class>
<Class name="Desenvolvimento.utils.testesUnitarios">
<Abstract>1</Abstract>
<Super>%RegisteredObject,%UnitTest.TestCase</Super>
<TimeChanged>66190,28375.810302</TimeChanged>
<TimeCreated>66011,73920.240532</TimeCreated>
<Parameter name="DIRETORIOTEMPORARIO">
<Expression>^%SYS("TempDir")</Expression>
</Parameter>
<Parameter name="DIRETORIOTESTESUNITARIOS">
<Expression>$NAMESPACE</Expression>
</Parameter>
<Parameter name="DIRETORIOARMAZENARTESTESUNITARIOS">
<Expression>..RetornaDiretorioArmazenarTestesUnitariosNormalizado()</Expression>
</Parameter>
<Method name="Executar">
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[ Return ..GerarAmbienteTestes()
]]></Implementation>
</Method>
<Method name="GerarAmbienteTestes">
<Private>1</Private>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
Try
{
Set Status = $System.Status.OK()
Do ..HabilitarVisualizacaoPortalTestes()
Do ..SetLocalTestesUnitarios()
$$$THROWONERROR(Status, ..ValidaPacoteExiste(..#PACOTECOLECAOTESTES))
$$$THROWONERROR(Status, ..ExportarTodasClassesIndividualmente())
$$$THROWONERROR(Status, ..ExecutaTestesUnitarios() )
}
Catch ex
{
Set Status = ex.AsStatus()
}
Quit Status
]]></Implementation>
</Method>
<Method name="ValidaPacoteExiste">
<FormalSpec>PacoteColecaoTestes:%String=""</FormalSpec>
<Private>1</Private>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
Set Status = $System.Status.OK()
$$$THROWONERROR(Status,$System.OBJ.GetPackageList(.items,PacoteColecaoTestes))
Set contemItens = $DATA(items)
If ('contemItens)
{
$$$THROWONERROR(Status,$$$ERROR(5001,"Pacote "_PacoteColecaoTestes_" não encontrado"))
}
Quit Status
]]></Implementation>
</Method>
<Method name="ExportarTodasClassesIndividualmente">
<Private>1</Private>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[ Quit $System.OBJ.ExportAllClassesIndividual(..#DIRETORIOARMAZENARTESTESUNITARIOS,,,,..#PACOTECOLECAOTESTES)
]]></Implementation>
</Method>
<Method name="ExecutaTestesUnitarios">
<Private>1</Private>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[ Quit ##class(%UnitTest.Manager).RunTest(..#DIRETORIOARMAZENARTESTESUNITARIOS,"/nodelete")
]]></Implementation>
</Method>
<Method name="SetLocalTestesUnitarios">
<Private>1</Private>
<Implementation><![CDATA[ Set ^UnitTestRoot = ..#DIRETORIOTEMPORARIO
]]></Implementation>
</Method>
<Method name="HabilitarVisualizacaoPortalTestes">
<Private>1</Private>
<Implementation><![CDATA[
Set namespace = $ZCONVERT($NAMESPACE,"L")
Set habilitado = ^SYS("Security","CSP","AllowPrefix","/csp/"_namespace_"/","%UnitTest.")
If ('habilitado)
{
Set ^SYS("Security","CSP","AllowPrefix","/csp/"_namespace_"/","%UnitTest.") = 1
}
]]></Implementation>
</Method>
<Method name="RetornaDiretorioArmazenarTestesUnitariosNormalizado">
<ClassMethod>1</ClassMethod>
<ReturnType>%String</ReturnType>
<Implementation><![CDATA[ Return ##class(%Library.File).NormalizeDirectory(..#DIRETORIOTEMPORARIO_"/"_..#DIRETORIOTESTESUNITARIOS_"/")
]]></Implementation>
</Method>
</Class>
<Project name="TESTES UNITARIOS" LastModified="2022-03-22 07:53:13.940474" Target="##class(Desenvolvimento.testesUnitarios.CalculadoraTest).Run()" TargetType="2">
<Items>
<ProjectItem name="Desenvolvimento.utils.testesUnitarios" type="CLS"></ProjectItem>
<ProjectItem name="Desenvolvimento.testesUnitarios.CalculadoraTest" type="CLS"></ProjectItem>
<ProjectItem name="Desenvolvimento.Calculadora" type="CLS"></ProjectItem>
</Items>
<BreakPoints>
<BreakPoint Routine="Desenvolvimento.testesUnitarios.CalculadoraTest.CLS" Offset="ExecutarTestes+1"></BreakPoint>
<BreakPoint Routine="Desenvolvimento.utils.testesUnitarios.CLS" Offset="Executar+1"></BreakPoint>
<BreakPoint Routine="Desenvolvimento.utils.testesUnitarios.CLS" Offset="GerarAmbienteTestes+3"></BreakPoint>
</BreakPoints>
<WatchVariables>
<WatchVariable Variable="$System.Status.GetErrorText(Status)" Pane="1"></WatchVariable>
<WatchVariable Variable="teste" Pane="1"></WatchVariable>
<WatchVariable Variable="..#PACOTECOLECAOTESTES" Pane="1"></WatchVariable>
<WatchVariable Variable="..#DIRETORIOARMAZENARTESTESUNITARIOS" Pane="1"></WatchVariable>
</WatchVariables>
</Project>
</Export>