Quality should be considered from different perspectives:
Customer perspective.
Developer perspective.
Support Analyst perspective.
Sales and Marketing perspective.
You need to find a balance between these different views
of quality before releasing a product.
How much time and money you spend on quality and testing depends
essentially on economics. When failure is unthinkable, you spend
a lot more. For example:
Formal verification. That is, mathematically prove that software meets its specification. This is very expensive to do, but is performed today in a number of areas, verifying secure microkernels, for instance.