Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can any one explain Assert.AreEqual(true, true); with proper example and explanation?

share|improve this question

closed as unclear what you're asking by dzieciou, Kate Paulk, Dan Snell, corsiKa Apr 2 '14 at 15:34

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

Why you do you want to assert true is equal to true, is this a trick question? Maybe explain your use case in a bit more detail. Did you find this somewhere? – Niels van Reijmersdal Mar 19 '14 at 13:47
Can someone be brave enough to justify downvoting? – dzieciou Mar 19 '14 at 15:03
@dzieciou A downvote I believe is automatic when someone issues a vote to close. – corsiKa Mar 19 '14 at 15:16
@corsiKa, I have just voted to close and it did not get downvoted. – dzieciou Mar 19 '14 at 15:24
I down voted, there's no detail or context to the question – Phil Kirkham Mar 20 '14 at 11:24

You can use Assertions to verify something is in a certain state. Normally you compare the actual against the excepted state.

Example usage:

  • Do some steps in your application
  • Gather the value of a field
  • Assert that the value is indeed the value you expect

    Assert.AreEqual(Actual, Expected)

This could give an assertion failure if Actual and Expected differ. During a test run you should not have any assertion failures. :)

Asserts are often used in unit-tests and automated integration tests to give feedback or actually test something during a test run.

share|improve this answer

Can any one explain Assert.AreEqual(true, true)

Verifies that two specified objects are equal. The assertion fails if the objects are not equal. Displays a message if the assertion fails.

example and explanation?

Very simple NUnit test:

using System;
using NUnit.Framework;

namespace SampleUnitTest
  public Class SampleTest
    public void AddingOneAndOneResultsInTwo()
      int two = 1 + 1;

      Assert.AreEqual(2, two);

Explanation is simple too, integer value two equals 2 and then method Assert.AreEqual(2, two) compares two values 2 and two. That is, two references to the same object would evaluate as being equal; two clones of a same object would evaluate as being different. Unless you overload the Equals() instance method of the class(es) those objects belong to, or the == operator for said class(es). Also, I suggest you to read official documentation and answers on stackoverflow:

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.