phuccaoca123 / mb-unit

Automatically exported from code.google.com/p/mb-unit
0 stars 0 forks source link

Produce a compelling Xml testing story. #64

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
MbUnit v2 contained Xml testing code based on the XmlUnit distribution. 
(http://xmlunit.sourceforge.net/)  Unfortunately that code has languished
without any significant updates and is not very well known.  Time for a
changeup.  Let's learn from it and do better.

Goals:

1. Create a first-class, tightly-integrated and clearly documented
Xml-testing extension to MbUnit under the MbUnit.Framework.Xml namespace.

2. Identify interesting and common use-cases for Xml testing and make them
easier to support.  Examples are: XML serialization, XSLT, XPATH, XHTML
validation, SOAP message processing, and RSS.

3. Produce meaningful, readable and precise assertion failure messages when
mismatches occur.

4. Make it easy to obtain, process and describe differences between Xml
documents.

5. Support Xml namespaces with ease.

6. Use modern .Net 2.0 features such as generics where appropriate to
provide a better interface.

7. Investigate possible enhancements using .Net 3.5 features such as LINQ
to XML.

8. Write story-based documentation for the Xml testing components and
promote them widely.

I expect this work to be divided among several people working together to
produce a compelling Xml testing story for MbUnit.

Original issue reported on code.google.com by jeff.br...@gmail.com on 21 Sep 2007 at 8:07

GoogleCodeExporter commented 8 years ago

Original comment by jeff.br...@gmail.com on 30 Oct 2007 at 2:25

GoogleCodeExporter commented 8 years ago

Original comment by jeff.br...@gmail.com on 6 Jan 2008 at 7:19

GoogleCodeExporter commented 8 years ago

Original comment by jeff.br...@gmail.com on 17 Mar 2008 at 10:50

GoogleCodeExporter commented 8 years ago
Something to think about so we can replace XmlAssert.

Original comment by jeff.br...@gmail.com on 18 Sep 2008 at 8:17

GoogleCodeExporter commented 8 years ago
Let's see what we can do for v3.0.7 or v3.0.8.

Original comment by jeff.br...@gmail.com on 26 Apr 2009 at 8:11

GoogleCodeExporter commented 8 years ago
The more I think about this, the more I think it should be .Net 3.5 only so we 
can
use LINQ syntax for diffing XML trees (or other data structures like with the
structural equality comparer, maybe?)

Original comment by jeff.br...@gmail.com on 16 Jun 2009 at 7:44

GoogleCodeExporter commented 8 years ago

Original comment by jeff.br...@gmail.com on 29 Jun 2009 at 8:33

GoogleCodeExporter commented 8 years ago
The main reason I wanted to do this was so that we could deprecate and remove 
the old
Xml testing feature.  However it seems that tests involving Xml are not too 
common or
else people have effective ways of writing them.  We should perhaps just leave 
this
out until we get a solid feature request from a user.

Original comment by jeff.br...@gmail.com on 18 Jul 2009 at 5:06

GoogleCodeExporter commented 8 years ago
Assert.Xml.AreEqual complete.

Original comment by Yann.Tre...@gmail.com on 14 Sep 2009 at 6:46

GoogleCodeExporter commented 8 years ago
:-)

What's next?

Original comment by jeff.br...@gmail.com on 14 Sep 2009 at 7:12

GoogleCodeExporter commented 8 years ago
Mmh... That's a good question :)

Either we continue to work on solutions for testing XML in general (schemas, 
etc.), or 
we focus on more specialized features for XML-based things like SOAP or HTML.

Original comment by Yann.Tre...@gmail.com on 18 Sep 2009 at 5:30

GoogleCodeExporter commented 8 years ago
To give you guys a scenario of what I envision us doing (in our company):

We have DB structure, fills and migration steps defined in XML files. Between 
various
versions, service packs and customizations, merging is more or less 'hell' when 
it
comes to these XML's. My idea is to - per build - keep unit tests on these 
XML's, so
that I can always verify that all required content is there after a merge.

Doesn't have to be anything except the basic "check if element exists/doesn't 
exist",
"check attribute of element x", "element uniqueness", etc. Some of these things 
can
be checked by applying a schema, but for one or two reasons, this is not 
practical
(and in some cases, not even possible) for us. I.e support a subset of common 
XSD
validations.

Original comment by mikael.r...@gmail.com on 18 Sep 2009 at 6:24

GoogleCodeExporter commented 8 years ago
Oh thank you so much for your feedback, Mikael. 

Testing subsets of XML fragments for various matches and criteria could be 
indeed 
very interesting. More specifically, do you have some idea how the assertions 
would 
look like? How could we specify the location of an element/attribute to check?

Let's play:
Assert.Xml.Exists(myXmlData, "<Root><Parent><Child><ThisElementShouldExist>");
Assert.Xml.Exists(myXmlData, "<Root><Parent><Child><Element 
thisAttributeShouldExist>");
Assert.Xml.DoesNotExist(myXmlData, 
"<Root><Parent><Child><ThisElementShouldNotExist>");
Assert.Xml.DoesNotExist(myXmlData, "<Root><Parent><Child><Element 
thisAttributeShouldNotExist>");
Assert.Xml.AreEqual(myXmlData, "ExpectedValue", 
"<Root><Parent><Child><Element>");
Assert.Xml.AreEqual(myXmlData, "ExpectedValue", "<Root><Parent><Child><Element 
attribute>");
Assert.Xml.AreNotEqual(myXmlData, "UnexpectedValue", 
"<Root><Parent><Child><Element>");
Assert.Xml.AreNotEqual(myXmlData, "UnexpectedValue", 
"<Root><Parent><Child><Element 
attribute>");
Assert.Xml.IsUnique(myXmlData, 
"<Root><Parent><Child><ThisElementShouldBeUnique>");
etc.

I don't like too much this way to specify the location of an element (I just 
type as 
I think about it). We could perhaps have some kind of fluent syntax language: 
Fragment.Element("Root").Element("Parent").Element("Child").Element("Element").A
ttrib
ute("thisAttributeShouldExist")

We probably also need some options for element value equality when the seached 
element is not unique.

What do you think? Any suggestion?

Original comment by Yann.Tre...@gmail.com on 18 Sep 2009 at 7:09

GoogleCodeExporter commented 8 years ago
Assert.Xml.Exists complete 

Basically, it verifies the existence of a given element or attribute in the XML 
tree. 
The next step is to extend that assertion so that it supports verifications 
against a 
value as well.

Original comment by Yann.Tre...@gmail.com on 23 Sep 2009 at 9:34

GoogleCodeExporter commented 8 years ago
Assert.Xml.Exists with item value checking is complete.

Next steps are:
- Assert.Xml.IsUnique
- Negative assertions (AreNotEqual, DoesNotExist, and IsNotUnique)

Original comment by Yann.Tre...@gmail.com on 5 Oct 2009 at 9:30

GoogleCodeExporter commented 8 years ago
Assert.Xml.IsUnique is done.

Mmh... I think it will be enough for now.

Let see what is going to happen, and push possible other XML related assertions 
to 
v3.3.

Original comment by Yann.Tre...@gmail.com on 26 Oct 2009 at 7:14

GoogleCodeExporter commented 8 years ago
Sounds good.

Could you write an article about this feature and maybe a blurb that I can 
include in
the v3.2 release notes later?

Original comment by jeff.br...@gmail.com on 26 Oct 2009 at 7:36

GoogleCodeExporter commented 8 years ago
Yup.

Original comment by Yann.Tre...@gmail.com on 26 Oct 2009 at 7:38