Hi Michael,
Nice explanation.
Thanks
Michael Watzek wrote:
> Hi Karan,
>
> A positive test case is supposed to succeed. For example, you write a
> test case which updates a persistent instance and commits the
> transaction. Then you check if the update had an effect in the database.
>
> A negative test case is supposed to fail. Usually, a negative test
> case checks if the implementation throws the right exception. For
> example, you write a test case which checks if invalid identifiers in
> JDOQL queries are asserted.
>
> Regards,
> Michael
>
>> Hi Michael,
>>
>> I saw the wiki on query tests. Neat work. I had a question, what is
>> the difference between the positive test and negative test. Does that
>> have any affect on the way the testcase code is written?
>>
>> Regards
>>
>> Apache Wiki wrote:
>>
>>> Dear Wiki user,
>>>
>>> You have subscribed to a wiki page or wiki category on "Jdo Wiki"
>>> for change notification.
>>>
>>> The following page has been changed by MichaelWatzek:
>>> http://wiki.apache.org/jdo/QueryTests
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> ||<|3> '''A14.6.11-2:''' The default Unique setting is `true` for
>>> aggregate results without a grouping expression, and `false`
>>> otherwise. || '''`true:`'''[[BR]]`SELECT COUNT(THIS) FROM
>>> company.Person` ||<|3> `result.`[[BR]]`DefaultUnique` ||<|3>
>>> Positive test. ||
>>> || '''`false grouping:`'''[[BR]]`SELECT FROM company.Person` `GROUP
>>> BY lastname` ||
>>> || '''`false:`'''[[BR]]`SELECT FROM company.Person` ||
>>> - ||<|14> '''A14.6.12-1:''' The result class may be one of ... ...
>>> Portable result classes do not invoke any persistence behavior
>>> during their no-args constructor or set methods. || '''`valid,
>>> result class is String:`'''[[BR]]`SELECT stringNull INTO String FROM
>>> mylib.PrimitiveTypes`[[BR]]''`TBD for all supported JDK
>>> classes.`''||<|14> `result.`[[BR]]`ResultClassRequirements` ||<|14>
>>> Positive and negative test.[[BR]]New result class required. ||
>>> + ||<|14> '''A14.6.12-1:'''The result class may be one of the
>>> `java.lang` classes `Character`, `Boolea`, `Byte`, `Short`,
>>> `Integer`, `Long`, `Float`, `Double`, `String`, or `Object[]`; or
>>> one of the `java.math` classes `BigInteger` or `BigDecimal`; or the
>>> `java.util` class `Date`; or the `java.util` interface `Map`; or one
>>> of the `java.sql` classes `Date`, `Time`, or `Timestamp`; or a
>>> user-defined class.[[BR]]- If there are multiple result expressions,
>>> the result class must be able to hold all elements of the result
>>> specification or a `JDOUserException` is thrown.[[BR]]- If there is
>>> only one result expression, the result class must be assignable from
>>> the type of the result expression or must be able to hold all
>>> elements of the result specification. A single value must be able to
>>> be coerced into the specified result class (treating wrapper classes
>>> as equivalent to their unwrapped primitive types) or by matching. If
>>> the result class does not satisfy these conditions, a `JDOUser
>>> Exception` is thrown.[[BR]]- A constructor of a result class
>>> specified in the setResult method will be used if the results
>>> specification matches the parameters of the constructor by position
>>> and type. If more than one constructor satisfies the requirements,
>>> the JDO implementation chooses one of them. If no constructor
>>> satisfies the results requirements, or if the result class is
>>> specified via the `setResultClass` method, the following
>>> requirements apply:[[BR]]-- A user-defined result class must have a
>>> no-args constructor and one or more public “set” or “put”
>>> methods or fields.[[BR]]-- Each result expression must match one
>>> of:[[BR]]--- a public field that matches the name of the result
>>> expression and is of the type (treating wrapper types the same as
>>> primitive types) of the result expression;[[BR]]--- or if no public
>>> field matches the name and type, a public “set” method that
>>> returns `void` and matches the name of the result expression and
>>> takes a single parameter
>>> which is the exact type of the result expression;[[BR]]--- or if
>>> neither of the above applies, a public method must be found with the
>>> signature `void put(Object, Object)` in which the first argument is
>>> the name of the result expression and the second argument is the
>>> value from the query result.[[BR]]-- Portable result classes do not
>>> invoke any persistence behavior during their no-args constructor or
>>> set methods. || '''`valid, result class is String:`'''[[BR]]`SELECT
>>> stringNull INTO String FROM mylib.PrimitiveTypes`[[BR]]''`TBD for
>>> all supported JDK classes.`''||<|14>
>>> `result.`[[BR]]`ResultClassRequirements` ||<|14> Positive and
>>> negative test.[[BR]]New result class required. ||
>>> || '''`valid, result class is TCK class:`'''[[BR]]`SELECT
>>> stringNull AS s, intNotNull AS i` `INTO ...StringIntResult` `FROM
>>> mylib.PrimitiveTypes`||
>>> || '''`invalid, result class is TCK class` `not having Long
>>> property:`'''[[BR]]`SELECT stringNull AS s, longNotNull AS l` `INTO
>>> ...StringIntResult` `FROM mylib.PrimitiveTypes`||
>>> || '''`invalid, result class is JDK class:`'''[[BR]]`SELECT
>>> stringNull, intNotNull` `INTO String` `FROM mylib.PrimitiveTypes`||
>>> @@ -214, +214 @@
>>>
>>> || '''`invalid, result class is TCK class` `not having an no-arg
>>> constructor:`'''[[BR]]`SELECT stringNull INTO ...NoArgConstructor`
>>> `FROM mylib.PrimitiveTypes`||
>>> || '''`invalid, result class is TCK class` `not having public
>>> fields and methods:`'''[[BR]]`SELECT stringNull INTO
>>> ...NoFieldsNoMethods` `FROM mylib.PrimitiveTypes`||
>>> || '''`valid, result class is TCK class` `having public fields and
>>> set methods:`'''[[BR]]`SELECT stringNull AS s INTO
>>> ...FieldsAndSetMethods` `FROM mylib.PrimitiveTypes`||
>>> - || '''`valid, result class is TCK class` `having public fields and
>>> put method:`'''[[BR]]`SELECT stringNull AS s INTO
>>> ...FieldsAndPutMethod` `FROM mylib.PrimitiveTypes`||
>>> + || '''`valid, result class is TCK class` `having public fields and
>>> a put method:`'''[[BR]]`SELECT stringNull AS s INTO
>>> ...FieldsAndPutMethod` `FROM mylib.PrimitiveTypes`||
>>> || '''`valid, result class is TCK class` `having put
>>> method:`'''[[BR]]`SELECT stringNull AS s INTO ...PutMethod` `FROM
>>> mylib.PrimitiveTypes`||
>>> || '''A14.6.12-2:''' Table 6: Shape of Result (C is the candidate
>>> class) || `...` || `result.`[[BR]]`ShapeOfResult` || Positive test. ||
>>>
>>>
>>>
>>>
>>
>
>
--
Karan Singh
|