Skip to content

Assertion shouldn't traverse class properties tree #308

@kornelf

Description

@kornelf

I try to use your framework to writing Selenium WebDriver tests. But whent fluentassetions try to return an assertion error, then it starts to traverse all pageobject tree(15 levels down!), and it get a few hours to complete that single assert. Moreover if I have a list with 100000 elements, it will write it all! it's useless.

In my properties are many long time process references, so I don't want to traverse object tree for error message, because there is no data for that or it takes to long.

In configuration there is no option to remove Formatter object and repleace with my own, so I can't override this setting.

Propositions to resolve problem:

  1. Global configuration to just write type name or single ToString method(without traverse object)
  2. Formaters list should be full public

Example to show the problem:

public class Test
{
	[Fact]
	public void DoTest()
	{
		List<A> listOfC = new List<A>();

		for (int i = 0; i < 10000000; i++)
		{
			listOfC.Add(new A() { Prop1 = "test" });
		}

		listOfC.Should().HaveCount(x => x < 0, "message"); //it will be freezed for cuple hours
	}

	class A
	{

		private string prop1;

		public string Prop1
		{
			get
			{
				Thread.Sleep(40*1000); //delay, for example - http connection with 40s timeout
				//throw new Exception("It shouldn't get here!");  //also it can throw exceptions, and I know that, so I don't want to assert get here
				return prop1;
			}

			set
			{
				prop1 = value;
			}
		}
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions