You need to sign in to do that
Don't have an account?
EvertonSzekeres
Test class for trigger with delete
Hi !
I have this trigger
trigger DeletarProdutos_Qtd0 on Asset (after update) {
for(Asset ast:[SELECT quantity FROM Asset WHERE quantity = 0])
delete ast;
}
I don't know if this trigger have something wrong, but in my sandbox worked.
I'm facing trouble with the test class.
I tried this:
@isTest (Seealldata=true)
private class DeletarProdutos_Qtd0_test {
static testMethod void myUnitTest() {
Account acc = new Account(firstname='Teste', lastname='Test');
insert acc;
Asset ass = new Asset();
ass.name = 'SUPER ÁLBUM';
ass.quantity = 0;
ass.accountid = acc.id;
insert ass;
ass.quantity = 0;
ass.accountid = acc.id;
delete ass;
}
}
Thanks!
I have this trigger
trigger DeletarProdutos_Qtd0 on Asset (after update) {
for(Asset ast:[SELECT quantity FROM Asset WHERE quantity = 0])
delete ast;
}
I don't know if this trigger have something wrong, but in my sandbox worked.
I'm facing trouble with the test class.
I tried this:
@isTest (Seealldata=true)
private class DeletarProdutos_Qtd0_test {
static testMethod void myUnitTest() {
Account acc = new Account(firstname='Teste', lastname='Test');
insert acc;
Asset ass = new Asset();
ass.name = 'SUPER ÁLBUM';
ass.quantity = 0;
ass.accountid = acc.id;
insert ass;
ass.quantity = 0;
ass.accountid = acc.id;
delete ass;
}
}
Thanks!
Asset Ass1=new Asset([select id from Asset where name='SUPER ALBUM');
delete Ass1;
Please let me know if this helped.
Save error: SObject constructor must use name=value pairs
Asset Ass1=new Asset([select id from Asset where name='SUPER ALBUM' limit 1]);
delete Ass1;
I'm still getting the same error with the limit 1