Skip to main content
edited tags
Link
Adrian Larson
  • 151.3k
  • 38
  • 247
  • 431
added 10 characters in body
Source Link
Vamsi Krishna Gosu
  • 10.5k
  • 5
  • 33
  • 50

I wrote a test class for my batchable class. It works great but I want to limit the query of the test class only to the test object I have created.

So I have this inside my test method:

String query = 'SELECT Id, Name, ShipmentQuantity__c, CurrentQuantity__c FROM Stock__c WHERE Id =: ' + testStock.Id;

And then my test.StartTest():

system.test.startTest();
    Database.executeBatch(new IndependentBatch(query));
    system.test.stopTest();

The error I get is "System.QueryException: Variable does not exist: a0236000001bOXdAAM".

"System.QueryException: Variable does not exist: a0236000001bOXdAAM".

Obviously it sees the ID but I don't understand what the error means. If I erase the Where Id =: ' + testStock.Id;Where Id =: ' + testStock.Id; the test runs like a charm.

I wrote a test class for my batchable class. It works great but I want to limit the query of the test class only to the test object I have created.

So I have this inside my test method:

String query = 'SELECT Id, Name, ShipmentQuantity__c, CurrentQuantity__c FROM Stock__c WHERE Id =: ' + testStock.Id;

And then my test.StartTest():

system.test.startTest();
    Database.executeBatch(new IndependentBatch(query));
    system.test.stopTest();

The error I get is "System.QueryException: Variable does not exist: a0236000001bOXdAAM". Obviously it sees the ID but I don't understand what the error means. If I erase the Where Id =: ' + testStock.Id; the test runs like a charm.

I wrote a test class for my batchable class. It works great but I want to limit the query of the test class only to the test object I have created.

So I have this inside my test method:

String query = 'SELECT Id, Name, ShipmentQuantity__c, CurrentQuantity__c FROM Stock__c WHERE Id =: ' + testStock.Id;

And then my test.StartTest():

system.test.startTest();
Database.executeBatch(new IndependentBatch(query));
system.test.stopTest();

The error I get is

"System.QueryException: Variable does not exist: a0236000001bOXdAAM".

Obviously it sees the ID but I don't understand what the error means. If I erase the Where Id =: ' + testStock.Id; the test runs like a charm.

Source Link
Arthlete
  • 5k
  • 9
  • 61
  • 115

Test class for a batch - variable does not exist

I wrote a test class for my batchable class. It works great but I want to limit the query of the test class only to the test object I have created.

So I have this inside my test method:

String query = 'SELECT Id, Name, ShipmentQuantity__c, CurrentQuantity__c FROM Stock__c WHERE Id =: ' + testStock.Id;

And then my test.StartTest():

system.test.startTest();
    Database.executeBatch(new IndependentBatch(query));
    system.test.stopTest();

The error I get is "System.QueryException: Variable does not exist: a0236000001bOXdAAM". Obviously it sees the ID but I don't understand what the error means. If I erase the Where Id =: ' + testStock.Id; the test runs like a charm.