You need to sign in to do that
Don't have an account?
Valentin F.
Tests not entering into if/else
Hello everybody,
I needed to modify an apex class I deployed to production before.
The problem is that the code coverage is now 45% and I don't understand why it doesn't enter if neither if nor else.
I'm doing a callout into a future method, using HttpCalloutMock.
Main class example :
Test class :
I needed to modify an apex class I deployed to production before.
The problem is that the code coverage is now 45% and I don't understand why it doesn't enter if neither if nor else.
I'm doing a callout into a future method, using HttpCalloutMock.
Main class example :
Test class :
Test.startTest(); Test.setMock(HttpCalloutMock.class, new AppelAPIMock()); ExpeditionSearchDPD.updateExpe(expeditions); Test.stopTest();AppelAPIMock :
@isTest global with sharing class AppelAPIMock implements HTTPCalloutMock{ global HTTPResponse respond(HTTPRequest req){ HttpResponse res = new HTTPResponse(); res.setHeader('Content-Type', 'text/xml'); res.setBody('<?xml version="1.0" encoding="utf-8"?>' + '<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' + '<soap12:Body>' + '<getShipmentTraceResponse xmlns="http://www.cargonet.software/">' + '<getShipmentTraceResult>' + '<ShippingDate>02.08.2019</ShippingDate>' + '<DeliveryDate>05.08.2019</DeliveryDate>' + '<Weight>0</Weight>' + '</getShipmentTraceResult>' + '</getShipmentTraceResponse>' + '</soap12:Body>' + '</soap12:Envelope>'); res.setStatusCode(200); return res; } }Thank you for your answers
-greg
All Answers
PLZ. CHECK OUT MY PAGE OF APP CYBERFLIX.APK (https://cyberflixtv.info)
thanks
Valentin F.
Please provide values that satisfy the if and else condition, whenever it gets the values of if and else variable and satisfies the condition it will enter into them if and else
I specified in the AppelAPIMock class a value for 'DeliveryDate' as you can see.
It should be used as the ShippingDate juste before is.
Even when I'm hardcoding it directly in the Test.startTest();Test.stopTest(); it's not working
-greg
Thank you for your clue !