A Bayesian testing procedure for noninferiority trials with binary endpoints. The prior is constructed based on Bernstein polynomials with options for both informative and non-informative prior. The critical value of the test statistic (Bayes factor) is determined by minimizing total weighted error (TWE) criteria