+ Start a Discussion
GunnarGunnar 

Unit Tests Broke: Variable does not exist: name

Unit tests that have been in existence for some time, and pass, broke.

Created a new developer sandbox from our Production.

Ran all tests in the new sandbox.

A LOT of code is breaking.

The unit tests create their own data as such ...

// Create Account
    Account a01 = new Account();
    a01.name              = 'Guess Things Happen That Way';
    a01.ownerid           = JohnnyCash.id;

When it hits this line "a01.name              = 'Guess Things Happen That Way';"

It breaks, saying "Compile Error: Variable does not exist: name at line 31"

Again, this has been working for a LONG time, it's in a unit test.
Best Answer chosen by Gunnar
GunnarGunnar
That is an understandable idea and has merit.

However, you would think it fails in production too, where the sandbox comes from.

This was a brand new sandbox.

I dropped the instance of the sandbox.

Then re-created the sandbox.

Problem went away.

I've seen this before - where a brand new sandbox has an issue.

I always run all unit tests on a new sandbox. This is why.

Thanks.

All Answers

bob_buzzardbob_buzzard
When I've seen this type of errors in the past it is usually because there is a local class named Account, so the platform assumes you want a new instance of that rather than the account sobject.  Then when you attempt to access a field via the dotted notation, this is taken as a reference to a class property which doesn't exist.
GunnarGunnar
That is an understandable idea and has merit.

However, you would think it fails in production too, where the sandbox comes from.

This was a brand new sandbox.

I dropped the instance of the sandbox.

Then re-created the sandbox.

Problem went away.

I've seen this before - where a brand new sandbox has an issue.

I always run all unit tests on a new sandbox. This is why.

Thanks.
This was selected as the best answer