How to test a trigger?

AdamYAdamY Posts: 55 Bronze 3
edited October 7, 2013 10:22AM in SQL Test
TableA has Trigger1 that inserts data into TableB. I'd like to test that the trigger works correctly. Can I do that with SQL Test? I haven't been able to find a way yet. Does FakeTable handle triggers?

Comments

  • Hi AdamY,

    Thanks for your post. It looks like something simliar has been covered in stackoverflow:

    http://stackoverflow.com/questions/1355 ... e-triggers

    It looks like there is a workaround solution to make this happen.

    Best Regards,
    Steve
    _________________
    Steve Tanori
    Product Support
    Red Gate Software Ltd.
    866-997-0378
  • AdamYAdamY Posts: 55 Bronze 3
    kenbroz - the answer Steve (stanori) posted has a link to a work-around solution. tSQLt is working on a permanent solution, I think. The tSQLt Google Group is very helpful and has more info, too.
  • kenbroz wrote:
    why has been answered, I would like to know the answer because it has a similar problem.

    The latest version of tSQLt (the framework that underpins RedGate's SQL Test) now has an ApplyTrigger method which used in conjunction with FakeTable should allow you to do test your trigger. Not sure of this version is packaged up with SQL test yet though.

    I have successfully used SQL Test with a more recent build of tSQLt (based on the SQL script download via tsqlt.org) but YMMV.
    "Your mind is like a parachute, it works best when open" Frank Zappa
    "Be wary of strong drink. It can make you shoot at tax collectors…and miss" Robert Heinlein
    blog: http://datacentricity.net
    twitter: @datacentricity
Sign In or Register to comment.