Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7778409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:23:22+00:00 2026-06-01T18:23:22+00:00

Anyone please help me to write test case for 100% code coverage for following

  • 0

Anyone please help me to write test case for 100% code coverage for following trigger in apex

trigger ETicketAirlineUrlTrigger on E_Ticket__c (before insert, before update) {

  for(E_Ticket__c etNew : Trigger.New)
  {
    if(etNew.Airline__c =='Virgin Australia')
    {
        etNew.Airlines_Url__c = '<a href="http://www.virginaustralia.com/Personal/Bookings/Managebookings/index.htm">Virgin Australia</a>';
    }
    else if(etNew.Airline__c =='Virgin Atlantic')
    {
        etNew.Airlines_Url__c = '<a href="https://www.virgin-atlantic.com/en/us/manageyourflights/updatebooking/index.jsp">Virgin Atlantic</a>';
    }
    else if(etNew.Airline__c =='Virgin America')
    {
        etNew.Airlines_Url__c = '<a href="http://www.virginamerica.com/view-itinerary.html">Virgin America</a>';
    }
    else if(etNew.Airline__c =='US AIR')
    {
        etNew.Airlines_Url__c = '<a href="http://reservations.usairways.com/Default.aspx">US AIR</a>';
    }
    else if(etNew.Airline__c =='United Airlines')
    {
        etNew.Airlines_Url__c = '<a href="http://www.united.com/page/genericpage/0,,52172,00.html?navSource=dropDown&linkTitle=itineraries">United Airlines</a>';
    }
    else if(etNew.Airline__c =='Turkish Air')
    {
        etNew.Airlines_Url__c = '<a href="http://www4.thy.com/mybookings/reservations.tk?target=view&lang=en">Turkish Air</a>';
    }
    else if(etNew.Airline__c =='Thai Air')
    {
        etNew.Airlines_Url__c = '<a href="http://www.thaiair.com/AWR_PREM/view-trip.jsp">Thai Air</a>';
    }
    else if(etNew.Airline__c =='Swiss Airlines')
    {
        etNew.Airlines_Url__c = '<a href="http://www.swiss.com/web/EN/Pages/index.aspx?Country=US">Swiss Airlines</a>';
    }
    else if(etNew.Airline__c =='Southwest Airlines')
    {
        etNew.Airlines_Url__c = '<a href="https://www.southwest.com/flight/lookup-air-reservation.html?int=GSUBNAV-AIR-RETRIEVE&forceNe...">Southwest Airlines</a>';
    }
    else if(etNew.Airline__c =='South African')
    {
        etNew.Airlines_Url__c = '<a href="https://www.flysaa.com/Journeys/reservation/searchpnr.action?nameSpace=reservation">South African</a>';
    }
    else if(etNew.Airline__c =='Singapore Airlines')
    {
        etNew.Airlines_Url__c = '<a href="https://www.singaporeair.com/manageBooking-flow.form?execution=e1s1">Singapore Airlines</a>';
    }
    else if(etNew.Airline__c =='QATAR AIRWAYS')
    {
        etNew.Airlines_Url__c = '<a href="http://www.qatarairways.com/us/en/homepage.page">QATAR AIRWAYS</a>';
    }
    else if(etNew.Airline__c =='Qantas Airlines')
    {
        etNew.Airlines_Url__c = '<a href="http://www.qantas.com.au/travel/airlines/your-booking/global/en">Qantas Airlines</a>';
    }
    else if(etNew.Airline__c =='Malaysia')
    {
        etNew.Airlines_Url__c = '<a href="https://book.malaysiaairlines.com/itd/itd/lang/en/reservations">Malaysia</a>';
    }
    else if(etNew.Airline__c =='Lufthansa')
    {
        etNew.Airlines_Url__c = '<a href="http://www.lufthansa.com/online/portal/lh/us/my_account/my_bookings">Lufthansa</a>';
    }
    else if(etNew.Airline__c =='KLM - Royal Dutch Airlines')
    {
        etNew.Airlines_Url__c = '<a href="http://www.klm.com/travel/us_en/index.htm#tab=db_mmb">KLM - Royal Dutch Airlines</a>';
    }
    else if(etNew.Airline__c =='Japan Air')
    {
        etNew.Airlines_Url__c = '<a href="http://www.5971.jal.co.jp/eng/SearchReservation.do">Japan Air</a>';
    }
    else if(etNew.Airline__c =='Etihad Airlines')
    {
        etNew.Airlines_Url__c = '<a href="http://www.etihadairways.com/sites/etihad/_layouts/etihad/obe/RetrieveBooking.aspx">Etihad Airlines</a>';
    }
    else if(etNew.Airline__c =='Emirates')
    {
        etNew.Airlines_Url__c = '<a href="https://fly.emirates.com/MYB/MMBLogin.aspx">Emirates</a>';
    }
    else if(etNew.Airline__c =='Delta Airlines')
    {
        etNew.Airlines_Url__c = '<a href="http://www.delta.com/">Delta Airlines</a>';
    }
    else if(etNew.Airline__c =='Copa Airlines')
    {
        etNew.Airlines_Url__c = '<a href="http://www.copaair.com/sites/US/EN/Pages/homepage.aspx">Copa Airlines</a>';
    }
    else if(etNew.Airline__c =='Continental Airlines')
    {
        etNew.Airlines_Url__c = '<a href="http://www.continental.com/web/en-US/apps/reservation/default.aspx">Continental Airlines</a>';
    }
    else if(etNew.Airline__c =='Cathay Pacific')
    {
        etNew.Airlines_Url__c = '<a href="http://www.cathaypacific.com/cpa/en_US/manageyourtrip/managemybooking?loginType=nonmember">Cathay Pacific</a>';
    }
    else if(etNew.Airline__c =='British Airways')
    {
        etNew.Airlines_Url__c = '<a href="http://www.britishairways.com/travel/home/public/en_us">British Airways</a>';
    }
    else if(etNew.Airline__c =='American Airlines')
    {
        etNew.Airlines_Url__c = '<a href="https://www.aa.com/reservation/findReservationAccess.do">American Airlines</a>';
    }
    else if(etNew.Airline__c =='All Nippon')
    {
        etNew.Airlines_Url__c = '<a href="https://aswbe-i.ana.co.jp/p_per/sky_ip_per_jp/preReConfirmSearchPnr.do?CONNECTION_KIND=LAX&LA...">All Nippon</a>';
    }
    else if(etNew.Airline__c =='Alitalia')
    {
        etNew.Airlines_Url__c = '<a href="http://www.alitalia.com/US_EN/home/index.aspx">Alitalia</a>';
    }
    else if(etNew.Airline__c =='Alaska Airlines')
    {
        etNew.Airlines_Url__c = '<a href="https://www.alaskaair.com/booking/ssl/saved/ViewPnr.aspx">Alaska Airlines</a>';
    }
    else if(etNew.Airline__c =='Air New Zealand')
    {
        etNew.Airlines_Url__c = '<a href="https://flightbookings.airnewzealand.com/isbook_en_US/review/initNewWebCheckIn.do?workflowAction=...">Air New Zealand</a>';
    }
    else if(etNew.Airline__c =='Air France')
    {
        etNew.Airlines_Url__c = '<a href="https://www.airfrance.us/cgi-bin/AF/US/en/local/process/standard/rebooking/SearchPnrRbkAction.do?">Air France</a>';
    }
    else if(etNew.Airline__c =='Air Canada')
    {
        etNew.Airlines_Url__c = '<a href="http://www.aircanada.com/aco/manageMyBookings.do">Air Canada</a>';
    }
  }
}

And not able to get 100% code coverage using following test case

@isTest
private class ETicketAirlineUrlTestCase {

static testMethod void myUnitTest() {
    Opportunity oppNew =  new Opportunity();
    oppNew.Name = 'Test Opp';
    oppNew.StageName = 'To Be Searched';
    oppNew.CloseDate = System.now().date();
    insert oppNew;

    E_Ticket__c et =  new E_Ticket__c();
    et.Airline__c = 'Virgin Australia';
    et.Opportunity__c = oppNew.Id;
     et.Airline__c = 'Virgin Atlantic';
    insert et;

    E_Ticket__c etNew = [select Id, Airline__c from E_Ticket__c where Id = :et.Id];
    update etNew;
}
}

when i run Class–>Force.com–>Run Test it show 100% code coverage

but when i do Force.com–>Deploy To Server it show error 6% covered

Any help would be appreciated

Thanks..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:23:23+00:00Added an answer on June 1, 2026 at 6:23 pm

    Try this:

    @isTest
    private class ETicketAirlineUrlTestCase {
    
        static testMethod void myUnitTest() {
            Opportunity oppNew =  new Opportunity();
            oppNew.Name = 'Test Opp';
            oppNew.StageName = 'To Be Searched';
            oppNew.CloseDate = System.now().date();
            insert oppNew;
    
            List<E_Ticket__c> tickets = new List<E_Ticket__c>();
    
            E_Ticket__c et1 =  new E_Ticket__c();
            et1.Airline__c = 'Virgin Australia';
            et1.Opportunity__c = oppNew.Id;
            tickets.add(et1);
    
            E_Ticket__c et2 =  new E_Ticket__c();
            et2.Airline__c = 'Virgin Atlantic';
            et2.Opportunity__c = oppNew.Id;
            tickets.add(et2);
    
            // ...
            // add as many tickets needed for all Airlines
            // ...
    
            insert tickets;
            update tickets;
        }
    }
    

    Also, make sure custom objects match in both your sandbox and deployment/production server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone please help me to work out how to achieve the following? I
Could anyone please help me convert this code to vb.net, I have tried it
Can anyone please help. I'm following a tutorial found here as I have a
Can anyone please help me in writing rspec for the following method The write_entry_to_xml
Can anyone please help me to add video controls (play, pause, forward, seekbar) to
Could anyone please help me using C# Api in Z3. I have no idea
Can anyone please help me with this...I'm not very good with regular expressions and
Can anyone please help me to understand how should i access json data in
Can anyone please help me how to convert string to date I have 3
Ok so could anyone please help me out with the VB for auto entering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.